Changeset 112 for trunk/src/game/Level2.cpp
- Timestamp:
- 11/19/08 13:37:14 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Level2.cpp
r102 r112 43 43 #include <fstream> 44 44 #include <map> 45 #include "GlobalEvents.h" 45 46 46 47 static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = … … 100 101 } 101 102 102 if( security >= m_session->GetSecurity())103 if(m_session && security >= m_session->GetSecurity()) 103 104 { 104 105 SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); … … 166 167 } 167 168 168 if( security >= m_session->GetSecurity())169 if(m_session && security >= m_session->GetSecurity()) 169 170 { 170 171 SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); … … 556 557 bool ChatHandler::HandleLookupFactionCommand(const char* args) 557 558 { 558 if(!*args) 559 return false; 560 561 Player *target = getSelectedPlayer(); 562 if (!target) 563 { 564 SendSysMessage(LANG_NO_CHAR_SELECTED); 565 SetSentErrorMessage(true); 566 return false; 567 } 559 if (!*args) 560 return false; 561 562 // Can be NULL at console call 563 Player *target = getSelectedPlayer (); 568 564 569 565 std::string namepart = args; 570 566 std::wstring wnamepart; 571 567 572 if (!Utf8toWStr(namepart,wnamepart))568 if (!Utf8toWStr (namepart,wnamepart)) 573 569 return false; 574 570 575 571 // converting string that we try to find to lower case 576 wstrToLower ( wnamepart);572 wstrToLower (wnamepart); 577 573 578 574 uint32 counter = 0; // Counter for figure out that we found smth. 579 575 580 for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++) 581 //for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr) 582 { 583 FactionEntry const *factionEntry = sFactionStore.LookupEntry(id); 584 //FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID); 576 for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id) 577 { 578 FactionEntry const *factionEntry = sFactionStore.LookupEntry (id); 585 579 if (factionEntry) 586 580 { 587 FactionStateList::const_iterator repItr = target->m_factions.find(factionEntry->reputationListID); 588 589 int loc = m_session->GetSessionDbcLocale(); 581 FactionState const* repState = NULL; 582 if(target) 583 { 584 FactionStateList::const_iterator repItr = target->m_factions.find (factionEntry->reputationListID); 585 if(repItr != target->m_factions.end()) 586 repState = &repItr->second; 587 } 588 589 int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale(); 590 590 std::string name = factionEntry->name[loc]; 591 591 if(name.empty()) … … 597 597 for(; loc < MAX_LOCALE; ++loc) 598 598 { 599 if( loc==m_session->GetSessionDbcLocale())599 if(m_session && loc==m_session->GetSessionDbcLocale()) 600 600 continue; 601 601 … … 614 614 // or "id - [faction] [no reputation]" format 615 615 std::ostringstream ss; 616 ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; 617 618 if (repItr != target->m_factions.end()) 616 if (m_session) 617 ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r"; 618 else 619 ss << id << " - " << name << " " << localeNames[loc]; 620 621 if (repState) // and then target!=NULL also 619 622 { 620 623 ReputationRank rank = target->GetReputationRank(factionEntry); … … 623 626 ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")"; 624 627 625 if(rep Itr->second.Flags & FACTION_FLAG_VISIBLE)628 if(repState->Flags & FACTION_FLAG_VISIBLE) 626 629 ss << GetTrinityString(LANG_FACTION_VISIBLE); 627 if(rep Itr->second.Flags & FACTION_FLAG_AT_WAR)630 if(repState->Flags & FACTION_FLAG_AT_WAR) 628 631 ss << GetTrinityString(LANG_FACTION_ATWAR); 629 if(rep Itr->second.Flags & FACTION_FLAG_PEACE_FORCED)632 if(repState->Flags & FACTION_FLAG_PEACE_FORCED) 630 633 ss << GetTrinityString(LANG_FACTION_PEACE_FORCED); 631 if(rep Itr->second.Flags & FACTION_FLAG_HIDDEN)634 if(repState->Flags & FACTION_FLAG_HIDDEN) 632 635 ss << GetTrinityString(LANG_FACTION_HIDDEN); 633 if(rep Itr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED)636 if(repState->Flags & FACTION_FLAG_INVISIBLE_FORCED) 634 637 ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED); 635 if(rep Itr->second.Flags & FACTION_FLAG_INACTIVE)638 if(repState->Flags & FACTION_FLAG_INACTIVE) 636 639 ss << GetTrinityString(LANG_FACTION_INACTIVE); 637 640 } … … 1703 1706 } 1704 1707 1705 if( name==m_session->GetPlayer()->GetName())1708 if(m_session && name==m_session->GetPlayer()->GetName()) 1706 1709 { 1707 1710 SendSysMessage(LANG_COMMAND_KICKSELF); … … 1810 1813 username = fields[0].GetCppString(); 1811 1814 security = fields[1].GetUInt32(); 1812 if(m_session->GetSecurity() >= security) 1815 1816 if(!m_session || m_session->GetSecurity() >= security) 1813 1817 { 1814 1818 last_ip = fields[2].GetCppString(); … … 1892 1896 if (!px) 1893 1897 { 1898 if(!m_session) 1899 { 1900 SendSysMessage(LANG_PLAYER_NOT_FOUND); 1901 SetSentErrorMessage(true); 1902 return false; 1903 } 1904 1894 1905 size_t count; 1895 1906 QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket"); … … 1902 1913 count = 0; 1903 1914 1904 PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, m_session->GetPlayer()->isAcceptTickets() ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF)); 1915 bool accept = m_session->GetPlayer()->isAcceptTickets(); 1916 1917 PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, accept ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF)); 1905 1918 return true; 1906 1919 } … … 1909 1922 if(strncmp(px,"on",3) == 0) 1910 1923 { 1924 if(!m_session) 1925 { 1926 SendSysMessage(LANG_PLAYER_NOT_FOUND); 1927 SetSentErrorMessage(true); 1928 return false; 1929 } 1930 1911 1931 m_session->GetPlayer()->SetAcceptTicket(true); 1912 1932 SendSysMessage(LANG_COMMAND_TICKETON); … … 1917 1937 if(strncmp(px,"off",4) == 0) 1918 1938 { 1939 if(!m_session) 1940 { 1941 SendSysMessage(LANG_PLAYER_NOT_FOUND); 1942 SetSentErrorMessage(true); 1943 return false; 1944 } 1945 1919 1946 m_session->GetPlayer()->SetAcceptTicket(false); 1920 1947 SendSysMessage(LANG_COMMAND_TICKETOFF); … … 3591 3618 { 3592 3619 char const* active = activeEvents.find(id) != activeEvents.end() ? GetTrinityString(LANG_ACTIVE) : ""; 3593 PSendSysMessage(LANG_EVENT_ENTRY_LIST,id,id,descr.c_str(),active ); 3620 3621 if(m_session) 3622 PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,id,id,eventData.description.c_str(),active ); 3623 else 3624 PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,id,eventData.description.c_str(),active ); 3625 3594 3626 ++counter; 3595 3627 } … … 3616 3648 GameEventData const& eventData = events[event_id]; 3617 3649 3618 PSendSysMessage(LANG_EVENT_ENTRY_LIST,event_id,event_id,eventData.description.c_str(),active ); 3650 if(m_session) 3651 PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active ); 3652 else 3653 PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active ); 3654 3619 3655 ++counter; 3620 3656 } … … 3849 3885 } 3850 3886 3851 if (!*args)3887 if (!*args) 3852 3888 return false; 3853 3889 … … 3917 3953 { 3918 3954 3919 if (!*args)3920 return false; 3921 3922 std::string ip = strtok ((char*)args, " ");3923 char* limit_str = strtok(NULL, " ");3924 int32 limit = limit_str ? atoi(limit_str) : -1;3925 3926 loginDatabase.escape_string (ip);3927 3928 QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str());3929 3930 return LookupPlayerSearchCommand (result,limit);3955 if (!*args) 3956 return false; 3957 3958 std::string ip = strtok ((char*)args, " "); 3959 char* limit_str = strtok (NULL, " "); 3960 int32 limit = limit_str ? atoi (limit_str) : -1; 3961 3962 loginDatabase.escape_string (ip); 3963 3964 QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str ()); 3965 3966 return LookupPlayerSearchCommand (result,limit); 3931 3967 } 3932 3968 3933 3969 bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args) 3934 3970 { 3935 if (!*args)3936 return false; 3937 3938 std::string account = strtok ((char*)args, " ");3939 char* limit_str = strtok(NULL, " ");3940 int32 limit = limit_str ? atoi(limit_str) : -1;3941 3942 if (!AccountMgr::normilizeString(account))3943 return false; 3944 3945 loginDatabase.escape_string (account);3946 3947 QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str());3948 3949 return LookupPlayerSearchCommand (result,limit);3971 if (!*args) 3972 return false; 3973 3974 std::string account = strtok ((char*)args, " "); 3975 char* limit_str = strtok (NULL, " "); 3976 int32 limit = limit_str ? atoi (limit_str) : -1; 3977 3978 if (!AccountMgr::normilizeString (account)) 3979 return false; 3980 3981 loginDatabase.escape_string (account); 3982 3983 QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str ()); 3984 3985 return LookupPlayerSearchCommand (result,limit); 3950 3986 } 3951 3987 … … 3953 3989 { 3954 3990 3955 if (!*args)3956 return false; 3957 3958 std::string email = strtok ((char*)args, " ");3959 char* limit_str = strtok(NULL, " ");3960 int32 limit = limit_str ? atoi(limit_str) : -1;3961 3962 loginDatabase.escape_string (email);3963 3964 QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str());3965 3966 return LookupPlayerSearchCommand (result,limit);3991 if (!*args) 3992 return false; 3993 3994 std::string email = strtok ((char*)args, " "); 3995 char* limit_str = strtok (NULL, " "); 3996 int32 limit = limit_str ? atoi (limit_str) : -1; 3997 3998 loginDatabase.escape_string (email); 3999 4000 QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str ()); 4001 4002 return LookupPlayerSearchCommand (result,limit); 3967 4003 } 3968 4004 … … 4010 4046 return true; 4011 4047 } 4048 4049 /// Triggering corpses expire check in world 4050 bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/) 4051 { 4052 CorpsesErase(); 4053 return true; 4054 }