Changeset 177

Show
Ignore:
Timestamp:
11/19/08 13:43:30 (17 years ago)
Author:
yumileroy
Message:

[svn] * Avoid access to bag item prototype for getting bag size, use related item
update field instead as more fast source. source mangos.
* Further reduce of DB access in guild handlers.
* Multi-locale DBC extracting - source Foks

*** Devs not responsible if all your player items drop to the ground and get eaten by ants or rabbits.. or some kind of wierd ant-rabbits..

Original author: KingPin?
Date: 2008-11-06 08:20:26-06:00

Location:
trunk
Files:
20 modified

Legend:

Unmodified
Added
Removed
  • trunk/contrib/extractor/System.cpp

    r2 r177  
    4040int extract = EXTRACT_MAP | EXTRACT_DBC; 
    4141 
    42 static char* const langs[]={"deDE", "enGB", "enUS", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; 
     42static char* const langs[]={"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; 
    4343#define LANG_COUNT 12 
    4444 
     
    168168    CreateDir(path); 
    169169 
    170     for(int x = 0; x < ADT_RES; ++x) 
    171     { 
    172         for(int y = 0; y < ADT_RES; ++y) 
    173         { 
    174             for(int z = 0; z < map_count; ++z) 
     170    for(unsigned int x = 0; x < ADT_RES; ++x) 
     171    { 
     172        for(unsigned int y = 0; y < ADT_RES; ++y) 
     173        { 
     174            for(unsigned int z = 0; z < map_count; ++z) 
    175175            { 
    176176                sprintf(mpq_filename,"World\\Maps\\%s\\%s_%u_%u.adt",map_ids[z].name,map_ids[z].name,x,y); 
     
    190190//bool WMO(char* filename); 
    191191 
    192 void ExtractDBCFiles() 
     192void ExtractDBCFiles(int locale, bool basicLocale) 
    193193{ 
    194194    printf("Extracting dbc files...\n"); 
     
    199199    for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) 
    200200    { 
    201         vector<string> files = (*i)->GetFileList(); 
     201        vector<string> files; 
     202        (*i)->GetFileListTo(files); 
    202203        for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter) 
    203204            if (iter->rfind(".dbc") == iter->length() - strlen(".dbc")) 
     
    205206    } 
    206207 
    207     std::string path = output_path; 
     208    string path = output_path; 
    208209    path += "/dbc/"; 
    209210    CreateDir(path); 
     211    if(!basicLocale) 
     212    { 
     213        path += langs[locale]; 
     214        path += "/"; 
     215        CreateDir(path); 
     216    } 
    210217 
    211218    // extract DBCs 
     
    213220    for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) 
    214221    { 
    215         string filename = output_path; 
    216         filename += "/dbc/"; 
     222        string filename = path; 
    217223        filename += (iter->c_str() + strlen("DBFilesClient\\")); 
    218  
    219         //cout << filename << endl; 
    220224 
    221225        FILE *output=fopen(filename.c_str(),"wb"); 
     
    232236        ++count; 
    233237    } 
    234     printf("Extracted %u DBC files\n", count); 
    235 } 
    236  
    237 int GetLocale() 
    238 { 
     238    printf("Extracted %u DBC files\n\n", count); 
     239} 
     240 
     241void LoadLocaleMPQFiles(int const locale) 
     242{ 
     243    char filename[512]; 
     244 
     245    sprintf(filename,"%s/Data/%s/locale-%s.MPQ",input_path,langs[locale],langs[locale]); 
     246    new MPQArchive(filename); 
     247 
     248    for(int i = 1; i < 5; ++i) 
     249    { 
     250        char ext[3] = ""; 
     251        if(i > 1) 
     252            sprintf(ext, "-%i", i); 
     253 
     254        sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ",input_path,langs[locale],langs[locale],ext); 
     255        if(FileExists(filename)) 
     256            new MPQArchive(filename); 
     257    } 
     258} 
     259     
     260void LoadCommonMPQFiles() 
     261{ 
     262    char filename[512]; 
     263 
     264    sprintf(filename,"%s/Data/common.MPQ",input_path); 
     265    new MPQArchive(filename); 
     266    sprintf(filename,"%s/Data/expansion.MPQ",input_path); 
     267    new MPQArchive(filename); 
     268    for(int i = 1; i < 5; ++i) 
     269    { 
     270        char ext[3] = ""; 
     271        if(i > 1) 
     272            sprintf(ext, "-%i", i); 
     273            if(FileExists(filename)) 
     274                new MPQArchive(filename); 
     275    } 
     276} 
     277 
     278inline void CloseMPQFiles() 
     279{ 
     280    for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end();++j) (*j)->close(); 
     281        gOpenArchives.clear(); 
     282} 
     283 
     284int main(int argc, char * arg[]) 
     285{ 
     286    printf("Map & DBC Extractor\n"); 
     287    printf("===================\n\n"); 
     288 
     289    HandleArgs(argc, arg); 
     290 
     291    int FirstLocale = -1; 
     292     
    239293    for (int i = 0; i < LANG_COUNT; i++) 
    240294    { 
     
    244298        { 
    245299            printf("Detected locale: %s\n", langs[i]); 
    246             return i; 
    247         } 
    248     } 
    249  
    250     printf("Could not detect locale.\n"); 
    251     return -1; 
    252 } 
    253  
    254 void LoadMPQFiles(int const locale) 
    255 { 
    256     char filename[512]; 
    257  
    258     sprintf(filename,"%s/Data/%s/locale-%s.MPQ",input_path,langs[locale],langs[locale]); 
    259     new MPQArchive(filename); 
    260  
    261     for(int i = 1; i < 5; ++i) 
    262     { 
    263         char ext[3] = ""; 
    264         if(i > 1) 
    265             sprintf(ext, "-%i", i); 
    266  
    267         sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ",input_path,langs[locale],langs[locale],ext); 
    268         if(!FileExists(filename)) 
    269             break; 
    270         new MPQArchive(filename); 
    271     } 
    272  
    273     //need those files only if extract maps 
    274     if(extract & EXTRACT_MAP) 
    275     { 
    276         sprintf(filename,"%s/Data/common.MPQ",input_path); 
    277         new MPQArchive(filename); 
    278         sprintf(filename,"%s/Data/expansion.MPQ",input_path); 
    279         new MPQArchive(filename); 
    280  
    281         for(int i = 1; i < 5; ++i) 
    282         { 
    283             char ext[3] = ""; 
    284             if(i > 1) 
    285                 sprintf(ext, "-%i", i); 
    286  
    287             sprintf(filename,"%s/Data/patch%s.MPQ",input_path,ext); 
    288             if(!FileExists(filename)) 
    289                 break; 
    290             new MPQArchive(filename); 
    291         } 
    292     } 
    293 } 
    294  
    295 int main(int argc, char * arg[]) 
    296 { 
    297     printf("Map & DBC Extractor\n"); 
    298     printf("===================\n"); 
    299  
    300     HandleArgs(argc, arg); 
    301  
    302     int const locale = GetLocale(); 
    303     if(locale < 0) 
    304         return 1; 
    305  
    306     LoadMPQFiles(locale); 
    307  
    308     if(extract & EXTRACT_DBC) 
    309         ExtractDBCFiles(); 
    310  
    311     if(extract & EXTRACT_MAP) 
     300             
     301            //Open MPQs 
     302            LoadLocaleMPQFiles(i); 
     303             
     304            if((extract & EXTRACT_DBC) == 0) 
     305            { 
     306                FirstLocale=i; 
     307                break; 
     308            } 
     309 
     310        //Extract DBC files 
     311        if(FirstLocale<0) 
     312        { 
     313            ExtractDBCFiles(i, true); 
     314            FirstLocale = i; 
     315        } 
     316        else  
     317            ExtractDBCFiles(i, false); 
     318         
     319            //Close MPQs 
     320            CloseMPQFiles(); 
     321        } 
     322    } 
     323 
     324    if(FirstLocale<0) 
     325    { 
     326        printf("No locales detected\n"); 
     327        return 0; 
     328    } 
     329     
     330    if (extract & EXTRACT_MAP) 
     331    { 
     332        printf("Using locale: %s\n", langs[FirstLocale]); 
     333         
     334        // Open MPQs 
     335        LoadLocaleMPQFiles(FirstLocale); 
     336        LoadCommonMPQFiles(); 
     337         
     338        // Extract maps 
    312339        ExtractMapsFromMpq(); 
    313340 
    314     //Close MPQs 
    315     for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) 
    316         (*i)->close(); 
    317     gOpenArchives.clear(); 
     341        // Close MPQs 
     342        CloseMPQFiles(); 
     343    } 
    318344 
    319345    return 0; 
  • trunk/contrib/extractor/libmpq/mpq.cpp

    r168 r177  
    200200 * This function returns some useful file information. 
    201201 */ 
    202 int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int number) { 
     202int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int unsigned number) { 
    203203        int blockindex = number; //-1; 
    204204        int i = 0; 
  • trunk/contrib/extractor/libmpq/mpq.h

    r2 r177  
    199199extern int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype); 
    200200//extern int libmpq_file_extract(mpq_archive *mpq_a, const int number); 
    201 extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int number); 
     201extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number); 
    202202extern char *libmpq_file_name(mpq_archive *mpq_a, const int number); 
    203203extern int libmpq_file_number(mpq_archive *mpq_a, const char *name); 
  • trunk/contrib/extractor/libmpq/parser.cpp

    r2 r177  
    8080 
    8181        /* now search for comment in this line */ 
    82         for (i = 0; i < strlen(line); i++) { 
     82        for (i = 0; i < int(strlen(line)); i++) { 
    8383                if (line[i] == '#') { 
    8484                        pos = i - 1; 
  • trunk/contrib/extractor/mpq_libmpq.cpp

    r2 r177  
    7272        } 
    7373 
    74         int fileno = blockindex; 
     74        uint32 fileno = blockindex; 
    7575 
    7676        //int fileno = libmpq_file_number(&mpq_a, filename); 
  • trunk/contrib/extractor/mpq_libmpq.h

    r2 r177  
    5252    } 
    5353 
    54     vector<string> GetFileList() { 
    55         vector<string> filelist; 
    56  
     54    void GetFileListTo(vector<string>& filelist) { 
    5755        mpq_hash hash = GetHashEntry("(listfile)"); 
    5856        uint32 blockindex = hash.blockindex; 
    5957 
    6058        if ((blockindex == 0xFFFFFFFF) || (blockindex == 0)) 
    61             return filelist; 
     59            return; 
    6260 
    6361        uint32 size = libmpq_file_info(&mpq_a, LIBMPQ_FILE_UNCOMPRESSED_SIZE, blockindex); 
     
    8078        } 
    8179 
    82         delete buffer; 
    83         return filelist; 
     80        delete[] buffer; 
    8481    } 
    8582}; 
  • trunk/src/game/Bag.cpp

    r102 r177  
    4040Bag::~Bag() 
    4141{ 
    42     for(int i = 0; i<MAX_BAG_SIZE; i++) 
    43     { 
    44         if(m_bagslot[i])    delete m_bagslot[i]; 
    45     } 
     42    for(int i = 0; i < MAX_BAG_SIZE; ++i) 
     43        if (m_bagslot[i]) 
     44             delete m_bagslot[i]; 
    4645} 
    4746 
     
    5049    Item::AddToWorld(); 
    5150 
    52     for(int i = 0; i<MAX_BAG_SIZE; i++) 
    53     { 
     51    for(uint32 i = 0;  i < GetBagSize(); ++i) 
    5452        if(m_bagslot[i]) 
    5553            m_bagslot[i]->AddToWorld(); 
    56     } 
    5754} 
    5855 
    5956void Bag::RemoveFromWorld() 
    6057{ 
    61     for(int i = 0; i<MAX_BAG_SIZE; i++) 
    62     { 
     58    for(uint32 i = 0; i < GetBagSize(); ++i) 
    6359        if(m_bagslot[i]) 
    6460            m_bagslot[i]->RemoveFromWorld(); 
    65     } 
    6661 
    6762    Item::RemoveFromWorld(); 
     
    112107 
    113108    // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`) 
    114     for (uint32 i = 0; i < GetProto()->ContainerSlots; i++) 
     109    for (int i = 0; i < MAX_BAG_SIZE; ++i) 
    115110    { 
    116111        SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0); 
     
    128123{ 
    129124    for (int i = 0; i < MAX_BAG_SIZE; i++) 
    130     { 
    131         if (m_bagslot[i]) 
    132         { 
     125        if (m_bagslot[i]) 
    133126            m_bagslot[i]->DeleteFromDB(); 
    134         } 
    135     } 
    136127 
    137128    Item::DeleteFromDB(); 
     
    140131uint32 Bag::GetFreeSlots() const 
    141132{ 
    142     uint32 ContainerSlots=GetProto()->ContainerSlots; 
    143133    uint32 slots = 0; 
    144     for (uint8 i=0; i <ContainerSlots; i++) 
     134    for (uint32 i=0; i < GetBagSize(); i++) 
    145135        if (!m_bagslot[i]) 
    146136            ++slots; 
     
    179169    Item::BuildCreateUpdateBlockForPlayer( data, target ); 
    180170 
    181     for (int i = 0; i < MAX_BAG_SIZE; i++) 
    182     { 
     171    for (uint32 i = 0; i < GetBagSize(); ++i) 
    183172        if(m_bagslot[i]) 
    184173            m_bagslot[i]->BuildCreateUpdateBlockForPlayer( data, target ); 
    185     } 
    186174} 
    187175 
     
    189177bool Bag::IsEmpty() const 
    190178{ 
    191     uint32 ContainerSlots=GetProto()->ContainerSlots; 
    192     for(uint32 i=0; i < ContainerSlots; i++) 
    193         if (m_bagslot[i]) return false; 
     179    for(uint32 i = 0; i < GetBagSize(); ++i) 
     180        if (m_bagslot[i]) 
     181            return false; 
    194182 
    195183    return true; 
     
    198186uint32 Bag::GetItemCount( uint32 item, Item* eItem ) const 
    199187{ 
    200     uint32 ContainerSlots=GetProto()->ContainerSlots; 
    201  
    202188    Item *pItem; 
    203189    uint32 count = 0; 
    204     for(uint32 i=0; i < ContainerSlots; i++) 
     190    for(uint32 i=0; i < GetBagSize(); ++i) 
    205191    { 
    206192        pItem = m_bagslot[i]; 
     
    211197    if(eItem && eItem->GetProto()->GemProperties) 
    212198    { 
    213         for(uint32 i=0; i < ContainerSlots; i++) 
     199        for(uint32 i=0; i < GetBagSize(); ++i) 
    214200        { 
    215201            pItem = m_bagslot[i]; 
     
    224210uint8 Bag::GetSlotByItemGUID(uint64 guid) const 
    225211{ 
    226     uint32 ContainerSlots=GetProto()->ContainerSlots; 
    227  
    228     for(uint32 i=0;i<ContainerSlots;i++) 
    229     { 
     212    for(uint32 i = 0; i < GetBagSize(); ++i) 
    230213        if(m_bagslot[i] != 0) 
    231214            if(m_bagslot[i]->GetGUID() == guid) 
    232215                return i; 
    233     } 
    234216    return NULL_SLOT; 
    235217} 
    236218 
    237 // Adds an item to a bag slot 
    238 // - slot can be NULL_SLOT, in that case function searchs for a free slot 
    239 // - Return values: 0 - item not added 
    240 //                  1 - item added to a free slot (and perhaps to a stack) 
    241 //                  2 - item added to a stack (item should be deleted) 
    242219Item* Bag::GetItemByPos( uint8 slot ) const 
    243220{ 
    244     ItemPrototype const *pBagProto = GetProto(); 
    245     if( pBagProto ) 
    246     { 
    247         if( slot < pBagProto->ContainerSlots ) 
    248             return m_bagslot[slot]; 
    249     } 
     221    if( slot < GetBagSize() ) 
     222        return m_bagslot[slot]; 
     223         
    250224    return NULL; 
    251225} 
  • trunk/src/game/Bag.h

    r102 r177  
    5353        bool IsEmpty() const; 
    5454        uint32 GetFreeSlots() const; 
     55        uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); } 
    5556 
    5657        // DB operations 
  • trunk/src/game/Chat.cpp

    r174 r177  
    379379    static ChatCommand npcCommandTable[] = 
    380380    { 
    381         { "say",            SEC_MODERATOR,      false, &ChatHandler::HandleSayCommand,                 "", NULL }, 
    382                 { "whisper",        SEC_MODERATOR,      false, &ChatHandler::HandleNpcWhisperCommand,          "", NULL }, 
    383                 { "yell",           SEC_MODERATOR,      false, &ChatHandler::HandleYellCommand,                "", NULL }, 
    384                 { "textemote",      SEC_MODERATOR,      false, &ChatHandler::HandleTextEmoteCommand,           "", NULL }, 
    385                 { "add",            SEC_GAMEMASTER,     false, &ChatHandler::HandleAddSpwCommand,              "", NULL }, 
    386                 { "delete",         SEC_GAMEMASTER,     false, &ChatHandler::HandleDelCreatureCommand,         "", NULL }, 
    387                 { "spawndist",      SEC_GAMEMASTER,     false, &ChatHandler::HandleSpawnDistCommand,           "", NULL }, 
    388                 { "spawntime",      SEC_GAMEMASTER,     false, &ChatHandler::HandleSpawnTimeCommand,           "", NULL }, 
    389                 { "factionid",      SEC_GAMEMASTER,     false, &ChatHandler::HandleFactionIdCommand,           "", NULL }, 
    390                 { "addmove",        SEC_GAMEMASTER,     false, &ChatHandler::HandleAddMoveCommand,             "", NULL }, 
    391                 { "setmovetype",    SEC_GAMEMASTER,     false, &ChatHandler::HandleSetMoveTypeCommand,         "", NULL }, 
    392                 { "move",           SEC_GAMEMASTER,     false, &ChatHandler::HandleMoveCreatureCommand,        "", NULL }, 
    393                 { "changelevel",    SEC_GAMEMASTER,     false, &ChatHandler::HandleChangeLevelCommand,         "", NULL }, 
    394                 { "setmodel",       SEC_GAMEMASTER,     false, &ChatHandler::HandleSetModelCommand,            "", NULL }, 
    395                 { "additem",        SEC_GAMEMASTER,     false, &ChatHandler::HandleAddVendorItemCommand,       "", NULL }, 
    396                 { "delitem",        SEC_GAMEMASTER,     false, &ChatHandler::HandleDelVendorItemCommand,       "", NULL }, 
    397                 { "flag",           SEC_GAMEMASTER,     false, &ChatHandler::HandleNPCFlagCommand,             "", NULL }, 
    398                 { "changeentry",    SEC_ADMINISTRATOR,  false, &ChatHandler::HandleChangeEntryCommand,         "", NULL }, 
    399                 { "info",           SEC_ADMINISTRATOR,  false, &ChatHandler::HandleNpcInfoCommand,             "", NULL }, 
    400                 { "playemote",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandlePlayEmoteCommand,           "", NULL }, 
     381        { "say",            SEC_MODERATOR,      false, &ChatHandler::HandleNpcSayCommand,              "", NULL }, 
     382        { "textemote",      SEC_MODERATOR,      false, &ChatHandler::HandleNpcTextEmoteCommand,        "", NULL }, 
     383        { "add",            SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcAddCommand,              "", NULL }, 
     384        { "delete",         SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcDeleteCommand,           "", NULL }, 
     385        { "spawndist",      SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcSpawnDistCommand,        "", NULL }, 
     386        { "spawntime",      SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcSpawnTimeCommand,        "", NULL }, 
     387        { "factionid",      SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcFactionIdCommand,        "", NULL }, 
     388        { "addmove",        SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcAddMoveCommand,          "", NULL }, 
     389        { "setmovetype",    SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcSetMoveTypeCommand,      "", NULL }, 
     390        { "move",           SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcMoveCommand,             "", NULL }, 
     391        { "changelevel",    SEC_GAMEMASTER,     false, &ChatHandler::HandleChangeLevelCommand,         "", NULL }, 
     392        { "setmodel",       SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcSetModelCommand,         "", NULL }, 
     393        { "additem",        SEC_GAMEMASTER,     false, &ChatHandler::HandleAddVendorItemCommand,       "", NULL }, 
     394        { "delitem",        SEC_GAMEMASTER,     false, &ChatHandler::HandleDelVendorItemCommand,       "", NULL }, 
     395        { "flag",           SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcFlagCommand,             "", NULL }, 
     396        { "changeentry",    SEC_ADMINISTRATOR,  false, &ChatHandler::HandleNpcChangeEntryCommand,      "", NULL }, 
     397        { "info",           SEC_ADMINISTRATOR,  false, &ChatHandler::HandleNpcInfoCommand,             "", NULL }, 
     398        { "playemote",      SEC_ADMINISTRATOR,  false, &ChatHandler::HandleNpcPlayEmoteCommand,        "", NULL }, 
    401399        { "follow",         SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcFollowCommand,           "", NULL }, 
    402400        { "unfollow",       SEC_GAMEMASTER,     false, &ChatHandler::HandleNpcUnFollowCommand,         "", NULL }, 
     401        { "whisper",        SEC_MODERATOR,      false, &ChatHandler::HandleNpcWhisperCommand,          "", NULL }, 
     402        { "yell",           SEC_MODERATOR,      false, &ChatHandler::HandleNpcYellCommand,             "", NULL }, 
    403403 
    404404        //{ TODO: fix or remove this commands 
  • trunk/src/game/Chat.h

    r174 r177  
    118118        bool HandleTaxiCheatCommand(const char* args); 
    119119        bool HandleWhispersCommand(const char* args); 
    120         bool HandleSayCommand(const char* args); 
    121         bool HandleNpcWhisperCommand(const char* args); 
    122         bool HandleYellCommand(const char* args); 
    123         bool HandlePlayEmoteCommand(const char* args); 
    124120        bool HandleSendMailCommand(const char* args); 
    125121        bool HandleNameTeleCommand(const char* args); 
     
    131127        bool HandleEventStopCommand(const char* args); 
    132128        bool HandleEventInfoCommand(const char* args); 
     129 
     130        bool HandleLearnCommand(const char* args); 
     131        bool HandleLearnAllCommand(const char* args); 
     132        bool HandleLearnAllGMCommand(const char* args); 
     133        bool HandleLearnAllCraftsCommand(const char* args); 
     134        bool HandleLearnAllRecipesCommand(const char* args); 
     135        bool HandleLearnAllDefaultCommand(const char* args); 
     136        bool HandleLearnAllLangCommand(const char* args); 
     137        bool HandleLearnAllMyClassCommand(const char* args); 
     138        bool HandleLearnAllMySpellsCommand(const char* args); 
     139        bool HandleLearnAllMyTalentsCommand(const char* args); 
     140 
     141        bool HandleLookupAreaCommand(const char* args); 
     142        bool HandleLookupCreatureCommand(const char* args); 
     143        bool HandleLookupEventCommand(const char* args); 
     144        bool HandleLookupFactionCommand(const char * args); 
     145        bool HandleLookupItemCommand(const char * args); 
     146        bool HandleLookupItemSetCommand(const char * args); 
     147        bool HandleLookupObjectCommand(const char* args); 
     148        bool HandleLookupPlayerIpCommand(const char* args); 
     149        bool HandleLookupPlayerAccountCommand(const char* args); 
     150        bool HandleLookupPlayerEmailCommand(const char* args); 
     151        bool HandleLookupQuestCommand(const char* args); 
     152        bool HandleLookupSkillCommand(const char* args); 
     153        bool HandleLookupSpellCommand(const char* args); 
     154        bool HandleLookupTeleCommand(const char * args); 
    133155 
    134156        bool HandleModifyKnownTitlesCommand(const char* args); 
     
    152174        bool HandleModifyRepCommand(const char* args); 
    153175        bool HandleModifyArenaCommand(const char* args); 
    154          
     176 
     177        bool HandleNpcAddCommand(const char* args); 
     178        bool HandleNpcAddMoveCommand(const char* args); 
     179        bool HandleNpcChangeEntryCommand(const char *args); 
     180        bool HandleNpcDeleteCommand(const char* args); 
     181        bool HandleNpcFactionIdCommand(const char* args); 
     182        bool HandleNpcFlagCommand(const char* args); 
    155183        bool HandleNpcFollowCommand(const char* args); 
     184        bool HandleNpcInfoCommand(const char* args); 
     185        bool HandleNpcMoveCommand(const char* args); 
     186        bool HandleNpcPlayEmoteCommand(const char* args); 
     187        bool HandleNpcSayCommand(const char* args); 
     188        bool HandleNpcSetModelCommand(const char* args); 
     189        bool HandleNpcSetMoveTypeCommand(const char* args); 
     190        bool HandleNpcSpawnDistCommand(const char* args); 
     191        bool HandleNpcSpawnTimeCommand(const char* args); 
     192        bool HandleNpcTextEmoteCommand(const char* args); 
    156193        bool HandleNpcUnFollowCommand(const char* args); 
     194        bool HandleNpcWhisperCommand(const char* args); 
     195        bool HandleNpcYellCommand(const char* args); 
    157196 
    158197        bool HandleReloadCommand(const char* args); 
     
    250289        bool HandleSubNameCommand(const char* args); 
    251290        bool HandleItemMoveCommand(const char* args); 
    252         bool HandleDelCreatureCommand(const char* args); 
    253291        bool HandleDeMorphCommand(const char* args); 
    254292        bool HandleAddVendorItemCommand(const char* args); 
    255293        bool HandleDelVendorItemCommand(const char* args); 
    256         bool HandleAddMoveCommand(const char* args); 
    257         bool HandleSetMoveTypeCommand(const char* args); 
    258294        bool HandleChangeLevelCommand(const char* args); 
    259295        bool HandleSetPoiCommand(const char* args); 
    260296        bool HandleEquipErrorCommand(const char* args); 
    261         bool HandleNPCFlagCommand(const char* args); 
    262         bool HandleSetModelCommand(const char* args); 
    263         bool HandleFactionIdCommand(const char* args); 
    264         bool HandleAddSpwCommand(const char* args); 
    265         bool HandleSpawnDistCommand(const char* args); 
    266         bool HandleSpawnTimeCommand(const char* args); 
    267297        bool HandleGoCreatureCommand(const char* args); 
    268298        bool HandleGoObjectCommand(const char* args); 
     
    271301        bool HandleTargetObjectCommand(const char* args); 
    272302        bool HandleDelObjectCommand(const char* args); 
    273         bool HandleMoveCreatureCommand(const char* args); 
    274303        bool HandleMoveObjectCommand(const char* args); 
    275304        bool HandleTurnObjectCommand(const char* args); 
     
    310339        bool HandleGoCommand(const char* args); 
    311340 
    312         bool HandleLearnCommand(const char* args); 
    313         bool HandleLearnAllCommand(const char* args); 
    314         bool HandleLearnAllGMCommand(const char* args); 
    315         bool HandleLearnAllCraftsCommand(const char* args); 
    316         bool HandleLearnAllRecipesCommand(const char* args); 
    317         bool HandleLearnAllDefaultCommand(const char* args); 
    318         bool HandleLearnAllLangCommand(const char* args); 
    319         bool HandleLearnAllMyClassCommand(const char* args); 
    320         bool HandleLearnAllMySpellsCommand(const char* args); 
    321         bool HandleLearnAllMyTalentsCommand(const char* args); 
    322  
    323         bool HandleLookupAreaCommand(const char* args); 
    324         bool HandleLookupCreatureCommand(const char* args); 
    325         bool HandleLookupEventCommand(const char* args); 
    326         bool HandleLookupFactionCommand(const char * args); 
    327         bool HandleLookupItemCommand(const char * args); 
    328         bool HandleLookupItemSetCommand(const char * args); 
    329         bool HandleLookupObjectCommand(const char* args); 
    330         bool HandleLookupPlayerIpCommand(const char* args); 
    331         bool HandleLookupPlayerAccountCommand(const char* args); 
    332         bool HandleLookupPlayerEmailCommand(const char* args); 
    333         bool HandleLookupQuestCommand(const char* args); 
    334         bool HandleLookupSkillCommand(const char* args); 
    335         bool HandleLookupSpellCommand(const char* args); 
    336         bool HandleLookupTeleCommand(const char * args); 
    337  
    338341        bool HandleCooldownCommand(const char* args); 
    339342        bool HandleUnLearnCommand(const char* args); 
     
    354357        bool HandleSpawnTransportCommand(const char* args); 
    355358        bool HandleExploreCheatCommand(const char* args); 
    356         bool HandleTextEmoteCommand(const char* args); 
    357         bool HandleNpcInfoCommand(const char* args); 
    358359        bool HandleHoverCommand(const char* args); 
    359360        bool HandleWaterwalkCommand(const char* args); 
     
    422423        bool HandleLoadPDumpCommand(const char *args); 
    423424        bool HandleWritePDumpCommand(const char *args); 
    424         bool HandleChangeEntryCommand(const char *args); 
    425425        bool HandleCastCommand(const char *args); 
    426426        bool HandleCastBackCommand(const char *args); 
  • trunk/src/game/Guild.h

    r173 r177  
    328328        } 
    329329        int32 GetRank(uint32 LowGuid); 
     330        bool IsMember(uint32 LowGuid) 
     331        { 
     332            return (members.find(LowGuid) != members.end()); 
     333        } 
    330334 
    331335        void Roster(WorldSession *session); 
  • trunk/src/game/GuildHandler.cpp

    r173 r177  
    153153 
    154154    std::string plName; 
    155     uint64 plGuid; 
    156     uint32 plGuildId; 
    157     Guild *guild; 
    158     Player *player; 
    159155 
    160156    //sLog.outDebug("WORLD: Received CMSG_GUILD_REMOVE"); 
     
    165161        return; 
    166162 
    167     guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 
     163    Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 
    168164    if(!guild) 
    169165    { 
     
    178174    } 
    179175     
    180     player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str()); 
    181     if(player) 
    182     { 
    183         plGuid = player->GetGUID(); 
    184         plGuildId = player->GetGuildId(); 
    185     } 
    186     else 
    187     { 
    188         plGuid = objmgr.GetPlayerGUIDByName(plName); 
    189         plGuildId = Player::GetGuildIdFromDB(plGuid); 
    190     } 
     176    uint64 plGuid = objmgr.GetPlayerGUIDByName(plName); 
    191177 
    192178    if(!plGuid) 
     
    202188    } 
    203189 
    204     if(GetPlayer()->GetGuildId() != plGuildId) 
     190    if(!guild->IsMember(GUID_LOPART(plGuid))) 
    205191    { 
    206192        SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S); 
     
    488474 
    489475    std::string name; 
    490     Player *newLeader; 
    491     uint64 newLeaderGUID; 
    492     uint32 newLeaderGuild; 
    493476    Player *oldLeader = GetPlayer(); 
    494477    Guild *guild; 
     
    503486    guild = objmgr.GetGuildById(oldLeader->GetGuildId()); 
    504487     
    505     if(!guild) 
     488    if (!guild) 
    506489    { 
    507490        SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 
     
    509492    } 
    510493     
    511     if(oldLeader->GetGUID() != guild->GetLeader()) 
     494    if( oldLeader->GetGUID() != guild->GetLeader()) 
    512495    { 
    513496        SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 
     
    515498    } 
    516499 
    517     newLeader = ObjectAccessor::Instance().FindPlayerByName(name.c_str()); 
    518     if(newLeader) 
    519     { 
    520         newLeaderGUID = newLeader->GetGUID(); 
    521         newLeaderGuild = newLeader->GetGuildId(); 
    522     } 
    523     else 
    524     { 
    525         newLeaderGUID = objmgr.GetPlayerGUIDByName(name); 
    526         newLeaderGuild = Player::GetGuildIdFromDB(newLeaderGUID); 
    527     } 
    528     if(!newLeaderGUID) 
     500    uint64 newLeaderGUID = objmgr.GetPlayerGUIDByName(name); 
     501    if (!newLeaderGUID) 
    529502    { 
    530503        SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND); 
    531504        return; 
    532505    } 
    533     if(oldLeader->GetGuildId() != newLeaderGuild) 
     506    if(!guild->IsMember(GUID_LOPART(newLeaderGUID))) 
    534507    { 
    535508        SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S); 
     
    589562    CHECK_PACKET_SIZE(recvPacket, 1); 
    590563 
    591     Guild *guild; 
    592     Player *player; 
    593     uint64 plGuid; 
    594     uint32 plGuildId; 
    595564    std::string name,PNOTE; 
    596565 
     
    602571        return; 
    603572 
    604     guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 
    605     if(!guild) 
     573    Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 
     574    if (!guild) 
    606575    { 
    607576        SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 
     
    609578    } 
    610579     
    611     if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EPNOTE)) 
     580    if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EPNOTE)) 
    612581    { 
    613582        SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 
     
    615584    } 
    616585     
    617     player = ObjectAccessor::Instance().FindPlayerByName(name.c_str()); 
    618     if(player) 
    619     { 
    620         plGuid = player->GetGUID(); 
    621         plGuildId = player->GetGuildId(); 
    622     } 
    623     else 
    624     { 
    625         plGuid = objmgr.GetPlayerGUIDByName(name); 
    626         plGuildId = Player::GetGuildIdFromDB(plGuid); 
    627     } 
    628  
    629     if(!plGuid) 
     586    uint64 plGuid = objmgr.GetPlayerGUIDByName(name); 
     587 
     588    if (!plGuid) 
    630589    { 
    631590        SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_FOUND); 
    632591        return; 
    633592    } 
    634     else if(GetPlayer()->GetGuildId() != plGuildId) 
     593     
     594    if (!guild->IsMember(GUID_LOPART(plGuid))) 
    635595    { 
    636596        SendGuildCommandResult(GUILD_INVITE_S, name, GUILD_PLAYER_NOT_IN_GUILD_S); 
     
    648608    CHECK_PACKET_SIZE(recvPacket, 1); 
    649609 
    650     Guild *guild; 
    651     Player *player; 
    652     uint64 plGuid; 
    653     uint32 plGuildId; 
    654610    std::string plName, OFFNOTE; 
    655611 
     
    661617        return; 
    662618 
    663     guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 
    664     if(!guild) 
     619    Guild* guild = objmgr.GetGuildById(GetPlayer()->GetGuildId()); 
     620    if (!guild) 
    665621    { 
    666622        SendGuildCommandResult(GUILD_CREATE_S, "", GUILD_PLAYER_NOT_IN_GUILD); 
    667623        return; 
    668624    } 
    669     if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EOFFNOTE)) 
     625    if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_EOFFNOTE)) 
    670626    { 
    671627        SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); 
     
    673629    } 
    674630     
    675     player = ObjectAccessor::Instance().FindPlayerByName(plName.c_str()); 
    676     if(player) 
    677     { 
    678         plGuid = player->GetGUID(); 
    679         plGuildId = player->GetGuildId(); 
    680     } 
    681     else 
    682     { 
    683         plGuid = objmgr.GetPlayerGUIDByName(plName); 
    684         plGuildId = Player::GetGuildIdFromDB(plGuid); 
    685     } 
    686  
    687     if( !plGuid ) 
     631    uint64 plGuid = objmgr.GetPlayerGUIDByName(plName); 
     632 
     633    if (!plGuid) 
    688634    { 
    689635        SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_FOUND); 
    690636        return; 
    691637    } 
    692     else if(GetPlayer()->GetGuildId() != plGuildId) 
     638     
     639    if (!guild->IsMember(GUID_LOPART(plGuid))) 
    693640    { 
    694641        SendGuildCommandResult(GUILD_INVITE_S, plName, GUILD_PLAYER_NOT_IN_GUILD_S); 
  • trunk/src/game/Language.h

    r163 r177  
    698698 
    699699        // Level 3 (continue) 
    700     LANG_MOTD_NEW                       = 1100, 
    701     LANG_ACCOUNT_SETADDON               = 1101, 
     700    LANG_ACCOUNT_SETADDON               = 1100, 
     701    LANG_MOTD_NEW                       = 1101, 
    702702    LANG_SENDMESSAGE                    = 1102, 
    703703    LANG_EVENT_ENTRY_LIST_CONSOLE       = 1103, 
  • trunk/src/game/Level1.cpp

    r132 r177  
    3939#endif 
    4040 
    41 bool ChatHandler::HandleSayCommand(const char* args) 
     41bool ChatHandler::HandleNpcSayCommand(const char* args) 
    4242{ 
    4343    if(!*args) 
     
    5757} 
    5858 
    59 bool ChatHandler::HandleYellCommand(const char* args) 
     59bool ChatHandler::HandleNpcYellCommand(const char* args) 
    6060{ 
    6161    if(!*args) 
     
    7676 
    7777//show text emote by creature in chat 
    78 bool ChatHandler::HandleTextEmoteCommand(const char* args) 
     78bool ChatHandler::HandleNpcTextEmoteCommand(const char* args) 
    7979{ 
    8080    if(!*args) 
  • trunk/src/game/Level2.cpp

    r173 r177  
    861861    dstslot = (uint8)atoi(pParam2); 
    862862 
     863    if(srcslot==dstslot) 
     864        return true; 
     865         
    863866    uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); 
    864867    uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); 
    865868 
    866     if(srcslot==dstslot) 
    867         return true; 
    868  
    869869    m_session->GetPlayer()->SwapItem( src, dst ); 
    870870 
     
    873873 
    874874//add spawn of creature 
    875 bool ChatHandler::HandleAddSpwCommand(const char* args) 
     875bool ChatHandler::HandleNpcAddCommand(const char* args) 
    876876{ 
    877877    if(!*args) 
     
    923923} 
    924924 
    925 bool ChatHandler::HandleDelCreatureCommand(const char* args) 
     925bool ChatHandler::HandleNpcDeleteCommand(const char* args) 
    926926{ 
    927927    Creature* unit = NULL; 
     
    10711071 
    10721072//move selected creature 
    1073 bool ChatHandler::HandleMoveCreatureCommand(const char* args) 
     1073bool ChatHandler::HandleNpcMoveCommand(const char* args) 
    10741074{ 
    10751075    uint32 lowguid = 0; 
     
    13241324 
    13251325//add move for creature 
    1326 bool ChatHandler::HandleAddMoveCommand(const char* args) 
     1326bool ChatHandler::HandleNpcAddMoveCommand(const char* args) 
    13271327{ 
    13281328    if(!*args) 
     
    13981398 *                       change the movement type 
    13991399 */ 
    1400 bool ChatHandler::HandleSetMoveTypeCommand(const char* args) 
     1400bool ChatHandler::HandleNpcSetMoveTypeCommand(const char* args) 
    14011401{ 
    14021402    if(!*args) 
     
    15261526 
    15271527    return true; 
    1528 }                                                           // HandleSetMoveTypeCommand 
     1528}                                                           // HandleNpcSetMoveTypeCommand 
    15291529 
    15301530//change level of creature or pet 
     
    15661566 
    15671567//set npcflag of creature 
    1568 bool ChatHandler::HandleNPCFlagCommand(const char* args) 
     1568bool ChatHandler::HandleNpcFlagCommand(const char* args) 
    15691569{ 
    15701570    if (!*args) 
     
    15921592 
    15931593//set model of creature 
    1594 bool ChatHandler::HandleSetModelCommand(const char* args) 
     1594bool ChatHandler::HandleNpcSetModelCommand(const char* args) 
    15951595{ 
    15961596    if (!*args) 
     
    16331633} 
    16341634 
    1635 //set faction of creature  or go 
    1636 bool ChatHandler::HandleFactionIdCommand(const char* args) 
     1635//set faction of creature 
     1636bool ChatHandler::HandleNpcFactionIdCommand(const char* args) 
    16371637{ 
    16381638    if (!*args) 
     
    21392139 
    21402140//set spawn dist of creature 
    2141 bool ChatHandler::HandleSpawnDistCommand(const char* args) 
     2141bool ChatHandler::HandleNpcSpawnDistCommand(const char* args) 
    21422142{ 
    21432143    if(!*args) 
     
    21772177} 
    21782178 
    2179 bool ChatHandler::HandleSpawnTimeCommand(const char* args) 
     2179bool ChatHandler::HandleNpcSpawnTimeCommand(const char* args) 
    21802180{ 
    21812181    if(!*args) 
  • trunk/src/game/Level3.cpp

    r174 r177  
    36573657 
    36583658//play npc emote 
    3659 bool ChatHandler::HandlePlayEmoteCommand(const char* args) 
     3659bool ChatHandler::HandleNpcPlayEmoteCommand(const char* args) 
    36603660{ 
    36613661    uint32 emote = atoi((char*)args); 
     
    55655565} 
    55665566 
    5567 bool ChatHandler::HandleChangeEntryCommand(const char *args) 
     5567bool ChatHandler::HandleNpcChangeEntryCommand(const char *args) 
    55685568{ 
    55695569    if(!args) 
  • trunk/src/game/Player.cpp

    r174 r177  
    39263926        for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 
    39273927            if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
    3928                 if(ItemPrototype const *pBagProto = pBag->GetProto()) 
    3929                     for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    3930                         if(Item* pItem = GetItemByPos( i, j )) 
    3931                             DurabilityLoss(pItem,percent); 
     3928                for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     3929                    if(Item* pItem = GetItemByPos( i, j )) 
     3930                        DurabilityLoss(pItem,percent); 
    39323931    } 
    39333932} 
     
    39713970        for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 
    39723971            if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
    3973                 if(ItemPrototype const *pBagProto = pBag->GetProto()) 
    3974                     for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    3975                         if(Item* pItem = GetItemByPos( i, j )) 
    3976                             DurabilityPointsLoss(pItem,points); 
     3972                for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     3973                    if(Item* pItem = GetItemByPos( i, j )) 
     3974                        DurabilityPointsLoss(pItem,points); 
    39773975    } 
    39783976} 
     
    83278325    } 
    83288326    Bag *pBag; 
    8329     ItemPrototype const *pBagProto; 
    83308327    for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 
    83318328    { 
     
    83338330        if( pBag ) 
    83348331        { 
    8335             pBagProto = pBag->GetProto(); 
    8336             if( pBagProto ) 
    8337             { 
    8338                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     8332            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     8333            { 
     8334                pItem = GetItemByPos( i, j ); 
     8335                if( pItem && pItem->GetEntry() == item ) 
    83398336                { 
    8340                     pItem = GetItemByPos( i, j ); 
    8341                     if( pItem && pItem->GetEntry() == item ) 
    8342                     { 
    8343                         tempcount += pItem->GetCount(); 
    8344                         if( tempcount >= count ) 
    8345                             return EQUIP_ERR_OK; 
    8346                     } 
     8337                    tempcount += pItem->GetCount(); 
     8338                    if( tempcount >= count ) 
     8339                        return EQUIP_ERR_OK; 
    83478340                } 
    83488341            } 
     
    84358428        if( pBag ) 
    84368429        { 
    8437             ItemPrototype const *pBagProto = pBag->GetProto(); 
    8438             if( pBagProto ) 
    8439             { 
    8440                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    8441                 { 
    8442                     Item* pItem = pBag->GetItemByPos( j ); 
    8443                     if( pItem && pItem->GetGUID() == guid ) 
    8444                         return pItem; 
    8445                 } 
     8430            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     8431            { 
     8432                Item* pItem = pBag->GetItemByPos( j ); 
     8433                if( pItem && pItem->GetGUID() == guid ) 
     8434                    return pItem; 
    84468435            } 
    84478436        } 
     
    84528441        if( pBag ) 
    84538442        { 
    8454             ItemPrototype const *pBagProto = pBag->GetProto(); 
    8455             if( pBagProto ) 
    8456             { 
    8457                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    8458                 { 
    8459                     Item* pItem = pBag->GetItemByPos( j ); 
    8460                     if( pItem && pItem->GetGUID() == guid ) 
    8461                         return pItem; 
    8462                 } 
     8443            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     8444            { 
     8445                Item* pItem = pBag->GetItemByPos( j ); 
     8446                if( pItem && pItem->GetGUID() == guid ) 
     8447                    return pItem; 
    84638448            } 
    84648449        } 
     
    86188603        if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
    86198604        { 
    8620             if(ItemPrototype const *pBagProto = pBag->GetProto()) 
    8621             { 
    8622                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     8605            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     8606            { 
     8607                Item* pItem = GetItemByPos( i, j ); 
     8608                if( pItem && pItem->GetEntry() == item ) 
     8609                { 
     8610                    tempcount += pItem->GetCount(); 
     8611                    if( tempcount >= count ) 
     8612                        return true; 
     8613                } 
     8614            } 
     8615        } 
     8616    } 
     8617 
     8618    if(inBankAlso) 
     8619    { 
     8620        for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) 
     8621        { 
     8622            Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 
     8623            if( pItem && pItem->GetEntry() == item ) 
     8624            { 
     8625                tempcount += pItem->GetCount(); 
     8626                if( tempcount >= count ) 
     8627                    return true; 
     8628            } 
     8629        } 
     8630        for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) 
     8631        { 
     8632            if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
     8633            { 
     8634                for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
    86238635                { 
    86248636                    Item* pItem = GetItemByPos( i, j ); 
     
    86348646    } 
    86358647 
    8636     if(inBankAlso) 
    8637     { 
    8638         for(int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; i++) 
    8639         { 
    8640             Item *pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 
    8641             if( pItem && pItem->GetEntry() == item ) 
    8642             { 
    8643                 tempcount += pItem->GetCount(); 
    8644                 if( tempcount >= count ) 
    8645                     return true; 
    8646             } 
    8647         } 
    8648         for(int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++) 
    8649         { 
    8650             if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
    8651             { 
    8652                 if(ItemPrototype const *pBagProto = pBag->GetProto()) 
    8653                 { 
    8654                     for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    8655                     { 
    8656                         Item* pItem = GetItemByPos( i, j ); 
    8657                         if( pItem && pItem->GetEntry() == item ) 
    8658                         { 
    8659                             tempcount += pItem->GetCount(); 
    8660                             if( tempcount >= count ) 
    8661                                 return true; 
    8662                         } 
    8663                     } 
    8664                 } 
    8665             } 
    8666         } 
    8667     } 
    8668  
    86698648    return false; 
    86708649} 
     
    87388717            return true; 
    87398718    } 
    8740     Bag *pBag; 
    8741     ItemPrototype const *pBagProto; 
    87428719    for(uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) 
    87438720    { 
    8744         pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 
    8745         if( pBag ) 
    8746         { 
    8747             pBagProto = pBag->GetProto(); 
    8748             if( pBagProto ) 
    8749             { 
    8750                 for(uint32 j = 0; j < pBagProto->ContainerSlots; ++j) 
    8751                 { 
    8752                     pItem = GetItemByPos( i, j ); 
    8753                     if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) 
    8754                         return true; 
    8755                 } 
     8721        if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
     8722        { 
     8723            for(uint32 j = 0; j < pBag->GetBagSize(); ++j) 
     8724            { 
     8725                pItem = GetItemByPos( i, j ); 
     8726                if( pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory )) 
     8727                    return true; 
    87568728            } 
    87578729        } 
     
    88478819        return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; 
    88488820 
    8849     for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     8821    for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
    88508822    { 
    88518823        // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot 
     
    93549326    for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 
    93559327    { 
    9356         Bag     *pBag; 
    9357         ItemPrototype const *pBagProto; 
    9358  
    9359         pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 
    9360         if( pBag ) 
    9361         { 
    9362             pBagProto = pBag->GetProto(); 
    9363  
    9364             if( pBagProto ) 
    9365             { 
    9366                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     9328        if(Bag* pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
     9329        { 
     9330            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     9331            { 
     9332                pItem2 = GetItemByPos( i, j ); 
     9333                if (pItem2 && !pItem2->IsInTrade()) 
    93679334                { 
    9368                     pItem2 = GetItemByPos( i, j ); 
    9369                     if (pItem2 && !pItem2->IsInTrade()) 
    9370                     { 
    9371                         inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); 
    9372                     } 
     9335                    inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); 
    93739336                } 
    93749337            } 
     
    94379400                if( pBag ) 
    94389401                { 
    9439                     pBagProto = pBag->GetProto(); 
    9440                     if( pBagProto ) 
     9402                    for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
    94419403                    { 
    9442                         for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     9404                        pItem2 = GetItemByPos( t, j ); 
     9405                        if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable ) 
    94439406                        { 
    9444                             pItem2 = GetItemByPos( t, j ); 
    9445                             if( pItem2 && pItem2->GetEntry() == pItem->GetEntry() && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->Stackable ) 
    9446                             { 
    9447                                 inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); 
    9448                                 b_found = true; 
    9449                                 break; 
    9450                             } 
     9407                            inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); 
     9408                            b_found = true; 
     9409                            break; 
    94519410                        } 
    94529411                    } 
     
    94879446                        ItemCanGoIntoBag(pProto,pBagProto) ) 
    94889447                    { 
    9489                         for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     9448                        for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
    94909449                        { 
    94919450                            if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) 
     
    95219480            if( pBag ) 
    95229481            { 
    9523                 pBagProto = pBag->GetProto(); 
    9524                 if( pBagProto && ItemCanGoIntoBag(pProto,pBagProto)) 
     9482                for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
    95259483                { 
    9526                     for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     9484                    if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) 
    95279485                    { 
    9528                         if( inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0 ) 
    9529                         { 
    9530                             inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; 
    9531                             b_found = true; 
    9532                             break; 
    9533                         } 
     9486                        inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; 
     9487                        b_found = true; 
     9488                        break; 
    95349489                    } 
    95359490                } 
     
    1062510580 
    1062610581    // in inventory bags 
    10627     Bag *pBag; 
    10628     ItemPrototype const *pBagProto; 
    1062910582    for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) 
    1063010583    { 
    10631         pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i ); 
    10632         if( pBag ) 
    10633         { 
    10634             pBagProto = pBag->GetProto(); 
    10635             if( pBagProto ) 
    10636             { 
    10637                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
     10584        if(Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, i )) 
     10585        { 
     10586            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     10587            { 
     10588                pItem = pBag->GetItemByPos(j); 
     10589                if( pItem && pItem->GetEntry() == item ) 
    1063810590                { 
    10639                     pItem = pBag->GetItemByPos(j); 
    10640                     if( pItem && pItem->GetEntry() == item ) 
     10591                    // all items in bags can be unequipped 
     10592                    if( pItem->GetCount() + remcount <= count ) 
    1064110593                    { 
    10642                         // all items in bags can be unequipped 
    10643                         if( pItem->GetCount() + remcount <= count ) 
    10644                         { 
    10645                             remcount += pItem->GetCount(); 
    10646                             DestroyItem( i, j, update ); 
    10647  
    10648                             if(remcount >=count) 
    10649                                 return; 
    10650                         } 
    10651                         else 
    10652                         { 
    10653                             pProto = pItem->GetProto(); 
    10654                             ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); 
    10655                             pItem->SetCount( pItem->GetCount() - count + remcount ); 
    10656                             if( IsInWorld() && update ) 
    10657                                 pItem->SendUpdateToPlayer( this ); 
    10658                             pItem->SetState(ITEM_CHANGED, this); 
     10594                        remcount += pItem->GetCount(); 
     10595                        DestroyItem( i, j, update ); 
     10596 
     10597                        if(remcount >=count) 
    1065910598                            return; 
    10660                         } 
     10599                    } 
     10600                    else 
     10601                    { 
     10602                        pProto = pItem->GetProto(); 
     10603                        ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); 
     10604                        pItem->SetCount( pItem->GetCount() - count + remcount ); 
     10605                        if( IsInWorld() && update ) 
     10606                            pItem->SendUpdateToPlayer( this ); 
     10607                        pItem->SetState(ITEM_CHANGED, this); 
     10608                        return; 
    1066110609                    } 
    1066210610                } 
     
    1072010668        if( pBag ) 
    1072110669        { 
    10722             ItemPrototype const *pBagProto = pBag->GetProto(); 
    10723             if( pBagProto ) 
    10724             { 
    10725                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    10726                 { 
    10727                     Item* pItem = pBag->GetItemByPos(j); 
    10728                     if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) 
    10729                         DestroyItem( i, j, update); 
    10730                 } 
     10670            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     10671            { 
     10672                Item* pItem = pBag->GetItemByPos(j); 
     10673                if( pItem && pItem->IsLimitedToAnotherMapOrZone(GetMapId(),new_zone) ) 
     10674                    DestroyItem( i, j, update); 
    1073110675            } 
    1073210676        } 
     
    1076410708        if( pBag ) 
    1076510709        { 
    10766             ItemPrototype const *pBagProto = pBag->GetProto(); 
    10767             if( pBagProto ) 
    10768             { 
    10769                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    10770                 { 
    10771                     Item* pItem = pBag->GetItemByPos(j); 
    10772                     if( pItem && pItem->GetProto() && 
    10773                         (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && 
    10774                         (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) 
    10775                         DestroyItem( i, j, update); 
    10776                 } 
     10710            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     10711            { 
     10712                Item* pItem = pBag->GetItemByPos(j); 
     10713                if( pItem && pItem->GetProto() && 
     10714                    (pItem->GetProto()->Class == ITEM_CLASS_CONSUMABLE) && 
     10715                    (pItem->GetProto()->Flags & ITEM_FLAGS_CONJURED) ) 
     10716                    DestroyItem( i, j, update); 
    1077710717            } 
    1077810718        } 
     
    1142311363        if( pBag ) 
    1142411364        { 
    11425             ItemPrototype const *pBagProto = pBag->GetProto(); 
    11426             if( pBagProto ) 
    11427             { 
    11428                 for(uint32 j = 0; j < pBagProto->ContainerSlots; j++) 
    11429                 { 
    11430                     Item* pItem = pBag->GetItemByPos(j); 
    11431                     if( pItem && pItem->GetEnchantmentId(slot) ) 
    11432                         pItem->ClearEnchantment(slot); 
    11433                 } 
     11365            for(uint32 j = 0; j < pBag->GetBagSize(); j++) 
     11366            { 
     11367                Item* pItem = pBag->GetItemByPos(j); 
     11368                if( pItem && pItem->GetEnchantmentId(slot) ) 
     11369                    pItem->ClearEnchantment(slot); 
    1143411370            } 
    1143511371        } 
     
    1571715653} 
    1571815654 
     15655void Player::PlaySound(uint32 Sound, bool OnlySelf) 
     15656{ 
     15657    WorldPacket data(SMSG_PLAY_SOUND, 4); 
     15658    data << Sound; 
     15659    if (OnlySelf) 
     15660        GetSession()->SendPacket( &data ); 
     15661    else 
     15662        SendMessageToSet( &data, true ); 
     15663} 
     15664 
    1571915665void Player::SendExplorationExperience(uint32 Area, uint32 Experience) 
    1572015666{ 
  • trunk/src/game/Player.h

    r174 r177  
    16061606        void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); 
    16071607 
     1608                //Low Level Packets 
     1609        void PlaySound(uint32 Sound, bool OnlySelf); 
    16081610        //notifiers 
    16091611        void SendAttackSwingCantAttack(); 
  • trunk/src/game/debugcmds.cpp

    r102 r177  
    320320            { 
    321321                Bag *bag = (Bag*)item; 
    322                 const ItemPrototype *proto = bag->GetProto(); 
    323                 for (uint8 j = 0; j < proto->ContainerSlots; ++j) 
     322                for (uint8 j = 0; j < bag->GetBagSize(); ++j) 
    324323                { 
    325324                    Item* item = bag->GetItemByPos(j); 
     
    417416            { 
    418417                Bag *bag = (Bag*)item; 
    419                 const ItemPrototype *proto = bag->GetProto(); 
    420                 for (uint8 j = 0; j < proto->ContainerSlots; ++j) 
     418                for (uint8 j = 0; j < bag->GetBagSize(); ++j) 
    421419                { 
    422420                    Item* item = bag->GetItemByPos(j);