Changeset 207 for trunk/src/game/Level2.cpp
- Timestamp:
- 11/19/08 13:46:22 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Level2.cpp
r177 r207 37 37 #include "SpellMgr.h" 38 38 #include "AccountMgr.h" 39 #include "GMTicketMgr.h" 39 40 #include "WaypointManager.h" 40 41 #include "Util.h" … … 863 864 if(srcslot==dstslot) 864 865 return true; 865 866 867 if(!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0,srcslot)) 868 return false; 869 870 if(!m_session->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0,dstslot)) 871 return false; 872 866 873 uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); 867 874 uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); … … 1796 1803 else 1797 1804 { 1798 QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", targetGUID);1805 QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", GUID_LOPART(targetGUID)); 1799 1806 if (!result) 1800 1807 { … … 1921 1928 } 1922 1929 1923 size_t count; 1924 QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket"); 1925 if(result) 1926 { 1927 count = (*result)[0].GetUInt32(); 1928 delete result; 1929 } 1930 else 1931 count = 0; 1930 size_t count = ticketmgr.GetTicketCount(); 1932 1931 1933 1932 bool accept = m_session->GetPlayer()->isAcceptTickets(); … … 1976 1975 { 1977 1976 PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); 1978 delete result;1979 1977 SetSentErrorMessage(true); 1980 1978 return false; … … 1983 1981 Field* fields = result->Fetch(); 1984 1982 1985 uint 64 guid = fields[0].GetUInt64();1983 uint32 guid = fields[0].GetUInt32(); 1986 1984 char const* text = fields[1].GetString(); 1987 1985 char const* time = fields[2].GetString(); 1988 1986 1989 ShowTicket( guid,text,time);1987 ShowTicket(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER),text,time); 1990 1988 delete result; 1991 1989 return true; … … 2007 2005 2008 2006 // ticket $char_name 2009 QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_text,ticket_lastchange FROM character_ticket WHERE guid = '%u' ORDER BY ticket_id ASC",GUID_LOPART(guid)); 2010 2011 if(!result) 2012 return false; 2013 2014 Field* fields = result->Fetch(); 2015 2016 char const* text = fields[0].GetString(); 2017 char const* time = fields[1].GetString(); 2018 2019 ShowTicket(guid,text,time); 2020 delete result; 2021 2022 return true; 2023 } 2024 2025 uint32 ChatHandler::GetTicketIDByNum(uint32 num) 2026 { 2027 QueryResult *result = CharacterDatabase.Query("SELECT ticket_id FROM character_ticket"); 2028 2029 if(!result || num > result->GetRowCount()) 2030 { 2031 PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); 2032 delete result; 2033 return 0; 2034 } 2035 2036 for(uint32 i = 1; i < num; ++i) 2037 result->NextRow(); 2038 2039 Field* fields = result->Fetch(); 2040 2041 uint32 id = fields[0].GetUInt32(); 2042 delete result; 2043 return id; 2007 GMTicket* ticket = ticketmgr.GetGMTicket(GUID_LOPART(guid)); 2008 if(!ticket) 2009 return false; 2010 2011 std::string time = TimeToTimestampStr(ticket->GetLastUpdate()); 2012 2013 ShowTicket(guid, ticket->GetText(), time.c_str()); 2014 2015 return true; 2044 2016 } 2045 2017 … … 2054 2026 if(strncmp(px,"all",4) == 0) 2055 2027 { 2056 QueryResult *result = CharacterDatabase.Query("SELECT guid FROM character_ticket"); 2057 2058 if(!result) 2059 return true; 2060 2061 // notify players about ticket deleting 2062 do 2063 { 2064 Field* fields = result->Fetch(); 2065 2066 uint64 guid = fields[0].GetUInt64(); 2067 2068 if(Player* sender = objmgr.GetPlayer(guid)) 2069 sender->GetSession()->SendGMTicketGetTicket(0x0A,0); 2070 2071 }while(result->NextRow()); 2072 2073 delete result; 2074 2075 CharacterDatabase.PExecute("DELETE FROM character_ticket"); 2028 ticketmgr.DeleteAll(); 2076 2029 SendSysMessage(LANG_COMMAND_ALLTICKETDELETED); 2077 2030 return true; … … 2083 2036 if(num > 0) 2084 2037 { 2085 QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_id,guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1); 2086 2038 QueryResult* result = CharacterDatabase.PQuery("SELECT guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1); 2087 2039 if(!result) 2088 2040 { 2089 2041 PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); 2090 delete result;2091 2042 SetSentErrorMessage(true); 2092 2043 return false; … … 2095 2046 Field* fields = result->Fetch(); 2096 2047 2097 uint32 id = fields[0].GetUInt32(); 2098 uint64 guid = fields[1].GetUInt64(); 2048 uint32 guid = fields[0].GetUInt32(); 2099 2049 delete result; 2100 2050 2101 CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE ticket_id = '%u'",id);2102 2103 // notify players about ticket deleting2104 if(Player* sender = objmgr.GetPlayer(guid))2105 { 2106 sender->GetSession()->SendGMTicketGetTicket(0x0A,0);2107 PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, sender->GetName());2051 ticketmgr.Delete(guid); 2052 2053 //notify player 2054 if(Player* pl = objmgr.GetPlayer(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER))) 2055 { 2056 pl->GetSession()->SendGMTicketGetTicket(0x0A, 0); 2057 PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, pl->GetName()); 2108 2058 } 2109 2059 else 2110 SendSysMessage(LANG_COMMAND_TICKETDEL);2060 PSendSysMessage(LANG_COMMAND_TICKETDEL); 2111 2061 2112 2062 return true; … … 2128 2078 2129 2079 // delticket $char_name 2130 CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",GUID_LOPART(guid));2080 ticketmgr.Delete(GUID_LOPART(guid)); 2131 2081 2132 2082 // notify players about ticket deleting