From 49307f6a13e26981351b90778201b075b71fc933 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 3 Nov 2008 15:53:49 +0300 Subject: [PATCH 1/3] Small fixes in genrevision --- src/tools/genrevision/genrevision.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/genrevision/genrevision.cpp b/src/tools/genrevision/genrevision.cpp index c66fd6d7b..9367addc1 100644 --- a/src/tools/genrevision/genrevision.cpp +++ b/src/tools/genrevision/genrevision.cpp @@ -98,7 +98,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& } else { - int res = sscanf(url_str,"git://%s",url_buf); + res = sscanf(url_str,"git://%s",url_buf); if(res) { host_str = strtok(url_buf,"/"); @@ -127,7 +127,7 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& char buf2[200]; char new_hash[200]; int unix_time = 0; - int res2 = sscanf(buf,"%s %s %s %s %i",buf2,new_hash,buf2,buf2,&unix_time,buf2); + int res2 = sscanf(buf,"%s %s %s %s %i",buf2,new_hash,buf2,buf2,&unix_time); if(res2!=5) continue; From 843a0d7d024df61ca8d1d15b87a815ba4446fcd7 Mon Sep 17 00:00:00 2001 From: hunuza Date: Mon, 3 Nov 2008 21:03:58 +0100 Subject: [PATCH 2/3] Cache GM tickets on server startup. --- src/game/Chat.h | 1 - src/game/GMTicketHandler.cpp | 179 ++++++++++++++++++++++++++++++++++ src/game/GMTicketMgr.cpp | 80 +++++++++++++++ src/game/GMTicketMgr.h | 118 ++++++++++++++++++++++ src/game/Level2.cpp | 94 ++++-------------- src/game/Makefile.am | 3 + src/game/MiscHandler.cpp | 183 ----------------------------------- src/game/World.cpp | 4 + win/VC71/game.vcproj | 9 ++ win/VC80/game.vcproj | 12 +++ win/VC90/game.vcproj | 12 +++ 11 files changed, 435 insertions(+), 260 deletions(-) create mode 100644 src/game/GMTicketHandler.cpp create mode 100644 src/game/GMTicketMgr.cpp create mode 100644 src/game/GMTicketMgr.h diff --git a/src/game/Chat.h b/src/game/Chat.h index 1967d0e28..28d1b3c8e 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -438,7 +438,6 @@ class ChatHandler // Utility methods for commands void ShowTicket(uint64 guid, char const* text, char const* time); - uint32 GetTicketIDByNum(uint32 num); bool LookupPlayerSearchCommand(QueryResult* result, int32 limit); bool HandleBanListHelper(QueryResult* result); bool HandleBanHelper(BanMode mode,char const* args); diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp new file mode 100644 index 000000000..0a7b65cc5 --- /dev/null +++ b/src/game/GMTicketHandler.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Language.h" +#include "WorldPacket.h" +#include "Log.h" +#include "GMTicketMgr.h" +#include "ObjectAccessor.h" +#include "Player.h" +#include "Chat.h" + +void WorldSession::SendGMTicketGetTicket(uint32 status, char const* text) +{ + int len = text ? strlen(text) : 0; + WorldPacket data( SMSG_GMTICKET_GETTICKET, (4+len+1+4+2+4+4) ); + data << uint32(status); // standard 0x0A, 0x06 if text present + if(status == 6) + { + data << text; // ticket text + data << uint8(0x7); // ticket category + data << float(0); // time from ticket creation? + data << float(0); // const + data << float(0); // const + data << uint8(0); // const + data << uint8(0); // const + } + SendPacket( &data ); +} + +void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ ) +{ + WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 ); + data << (uint32)time(NULL); + data << (uint32)0; + SendPacket( &data ); + + GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()); + if(ticket) + SendGMTicketGetTicket(0x06,ticket->GetText()); + else + SendGMTicketGetTicket(0x0A,0); +} + +void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,1); + + std::string ticketText; + recv_data >> ticketText; + + CharacterDatabase.escape_string(ticketText); + + if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) + ticket->SetText(ticketText.c_str()); + else + sLog.outError("Ticket update: Player %s (GUID: %u) doesn't have active ticket", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); +} + +void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/ ) +{ + ticketmgr.Delete(GetPlayer()->GetGUIDLow()); + + WorldPacket data( SMSG_GMTICKET_DELETETICKET, 4 ); + data << uint32(9); + SendPacket( &data ); + + SendGMTicketGetTicket(0x0A, 0); +} + +void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4); + + uint32 map; + float x, y, z; + std::string ticketText = ""; + uint32 unk1, unk2; + + recv_data >> map >> x >> y >> z; // last check 2.4.3 + recv_data >> ticketText; + + // recheck + CHECK_PACKET_SIZE(recv_data,4*4+(ticketText.size()+1)+2*4); + + recv_data >> unk1 >> unk2; + // note: the packet might contain more data, but the exact structure of that is unknown + + sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2); + + CharacterDatabase.escape_string(ticketText); + + if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow())) + { + WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); + data << uint32(1); + SendPacket( &data ); + return; + } + + ticketmgr.Create(_player->GetGUIDLow(), ticketText.c_str()); + + WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 ); + data << (uint32)time(NULL); + data << (uint32)0; + SendPacket( &data ); + + data.Initialize( SMSG_GMTICKET_CREATE, 4 ); + data << uint32(2); + SendPacket( &data ); + DEBUG_LOG("update the ticket\n"); + + //TODO: Guard player map + HashMapHolder::MapType &m = ObjectAccessor::Instance().GetPlayers(); + for(HashMapHolder::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) + { + if(itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets()) + ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName()); + } +} + +void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ ) +{ + WorldPacket data( SMSG_GMTICKET_SYSTEMSTATUS,4 ); + data << uint32(1); // we can also disable ticket system by sending 0 value + + SendPacket( &data ); +} + +void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data) +{ + // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3 + CHECK_PACKET_SIZE(recv_data,4+4); + uint32 x; + recv_data >> x; // answer range? (6 = 0-5?) + sLog.outDebug("SURVEY: X = %u", x); + + uint8 result[10]; + memset(result, 0, sizeof(result)); + for( int i = 0; i < 10; ++i) + { + CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+4); + uint32 questionID; + recv_data >> questionID; // GMSurveyQuestions.dbc + if (!questionID) + break; + + CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1+1); + uint8 value; + std::string unk_text; + recv_data >> value; // answer + recv_data >> unk_text; // always empty? + + result[i] = value; + sLog.outDebug("SURVEY: ID %u, value %u, text %s", questionID, value, unk_text.c_str()); + } + + CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1); + std::string comment; + recv_data >> comment; // addional comment + sLog.outDebug("SURVEY: comment %s", comment.c_str()); + + // TODO: chart this data in some way +} diff --git a/src/game/GMTicketMgr.cpp b/src/game/GMTicketMgr.cpp new file mode 100644 index 000000000..1fa41e780 --- /dev/null +++ b/src/game/GMTicketMgr.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "Common.h" +#include "Database/DatabaseEnv.h" +#include "Database/SQLStorage.h" +#include "GMTicketMgr.h" +#include "ObjectMgr.h" +#include "ProgressBar.h" +#include "Policies/SingletonImp.h" +#include "Player.h" +#include "ObjectDefines.h" + +INSTANTIATE_SINGLETON_1(GMTicketMgr); + +void GMTicketMgr::LoadGMTickets() +{ + m_GMTicketMap.clear(); // For reload case + + QueryResult *result = CharacterDatabase.Query( + // 0 1 2 + "SELECT guid, ticket_text,UNIX_TIMESTAMP(ticket_lastchange) FROM character_ticket"); + + if( !result ) + { + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outErrorDb(">> Loaded `character_ticket`, table is empty!"); + return; + } + + barGoLink bar( result->GetRowCount() ); + + uint32 count = 0; + + do + { + bar.step(); + + Field* fields = result->Fetch(); + + uint32 guid = fields[0].GetUInt32(); + m_GMTicketMap[guid] = GMTicket(guid, fields[1].GetCppString(), time_t(fields[2].GetUInt64())); + ++count; + + } while (result->NextRow()); + delete result; + + sLog.outString(); + sLog.outString( ">> Loaded %d GM tickets", count ); +} + +void GMTicketMgr::DeleteAll() +{ + for(GMTicketMap::iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr) + { + if(Player* owner = objmgr.GetPlayer(MAKE_NEW_GUID(itr->first,0,HIGHGUID_PLAYER))) + owner->GetSession()->SendGMTicketGetTicket(0x0A,0); + } + CharacterDatabase.PExecute("DELETE FROM character_ticket"); + m_GMTicketMap.clear(); +} diff --git a/src/game/GMTicketMgr.h b/src/game/GMTicketMgr.h new file mode 100644 index 000000000..6425c6865 --- /dev/null +++ b/src/game/GMTicketMgr.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2005-2008 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GMTICKETMGR_H +#define _GMTICKETMGR_H + +#include "Policies/Singleton.h" +#include "Database/DatabaseEnv.h" +#include "Util.h" +#include + +class GMTicket +{ + public: + explicit GMTicket() + { + } + + GMTicket(uint32 guid, std::string text, time_t update) : m_guid(guid), m_text(text), m_lastUpdate(update) + { + + } + + const char* GetText() const + { + return m_text.c_str(); + } + + uint64 GetLastUpdate() const + { + return m_lastUpdate; + } + + void SetText(const char* text) + { + m_text = text ? text : ""; + m_lastUpdate = time(NULL); + CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid); + } + + void DeleteFromDB() const + { + CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u' LIMIT 1", m_guid); + } + + void SaveToDB() const + { + CharacterDatabase.BeginTransaction(); + DeleteFromDB(); + CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText()); + CharacterDatabase.CommitTransaction(); + } + private: + uint32 m_guid; + std::string m_text; + time_t m_lastUpdate; +}; +typedef std::map GMTicketMap; + +class GMTicketMgr +{ + public: + GMTicketMgr() { } + ~GMTicketMgr() { } + + void LoadGMTickets(); + + GMTicket* GetGMTicket(uint32 guid) + { + GMTicketMap::iterator itr = m_GMTicketMap.find(guid); + if(itr == m_GMTicketMap.end()) + return NULL; + return &(itr->second); + } + + size_t GetTicketCount() const + { + return m_GMTicketMap.size(); + } + + void Delete(uint32 guid) + { + GMTicketMap::iterator itr = m_GMTicketMap.find(guid); + if(itr == m_GMTicketMap.end()) + return; + itr->second.DeleteFromDB(); + m_GMTicketMap.erase(itr); + } + + void DeleteAll(); + + void Create(uint32 guid, const char* text) + { + GMTicket t = GMTicket(guid, text, time(NULL)); + t.SaveToDB(); + m_GMTicketMap[guid] = t; + } + private: + GMTicketMap m_GMTicketMap; +}; + +#define ticketmgr MaNGOS::Singleton::Instance() +#endif \ No newline at end of file diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 9a4d6a138..e2c739070 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -34,6 +34,7 @@ #include "GameEvent.h" #include "SpellMgr.h" #include "AccountMgr.h" +#include "GMTicketMgr.h" #include "WaypointManager.h" #include "Util.h" #include @@ -1926,15 +1927,7 @@ bool ChatHandler::HandleTicketCommand(const char* args) return false; } - size_t count; - QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket"); - if(result) - { - count = (*result)[0].GetUInt32(); - delete result; - } - else - count = 0; + size_t count = ticketmgr.GetTicketCount(); bool accept = m_session->GetPlayer()->isAcceptTickets(); @@ -1981,18 +1974,17 @@ bool ChatHandler::HandleTicketCommand(const char* args) if(!result) { PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); - delete result; SetSentErrorMessage(true); return false; } Field* fields = result->Fetch(); - uint64 guid = fields[0].GetUInt64(); + uint32 guid = fields[0].GetUInt32(); char const* text = fields[1].GetString(); char const* time = fields[2].GetString(); - ShowTicket(guid,text,time); + ShowTicket(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER),text,time); delete result; return true; } @@ -2012,43 +2004,17 @@ bool ChatHandler::HandleTicketCommand(const char* args) return false; // ticket $char_name - QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_text,ticket_lastchange FROM character_ticket WHERE guid = '%u' ORDER BY ticket_id ASC",GUID_LOPART(guid)); - - if(!result) + GMTicket* ticket = ticketmgr.GetGMTicket(GUID_LOPART(guid)); + if(!ticket) return false; - Field* fields = result->Fetch(); + std::string time = TimeToTimestampStr(ticket->GetLastUpdate()); - char const* text = fields[0].GetString(); - char const* time = fields[1].GetString(); - - ShowTicket(guid,text,time); - delete result; + ShowTicket(guid, ticket->GetText(), time.c_str()); return true; } -uint32 ChatHandler::GetTicketIDByNum(uint32 num) -{ - QueryResult *result = CharacterDatabase.Query("SELECT ticket_id FROM character_ticket"); - - if(!result || num > result->GetRowCount()) - { - PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); - delete result; - return 0; - } - - for(uint32 i = 1; i < num; ++i) - result->NextRow(); - - Field* fields = result->Fetch(); - - uint32 id = fields[0].GetUInt32(); - delete result; - return id; -} - //dell all tickets bool ChatHandler::HandleDelTicketCommand(const char *args) { @@ -2059,26 +2025,7 @@ bool ChatHandler::HandleDelTicketCommand(const char *args) // delticket all if(strncmp(px,"all",4) == 0) { - QueryResult *result = CharacterDatabase.Query("SELECT guid FROM character_ticket"); - - if(!result) - return true; - - // notify players about ticket deleting - do - { - Field* fields = result->Fetch(); - - uint64 guid = fields[0].GetUInt64(); - - if(Player* sender = objmgr.GetPlayer(guid)) - sender->GetSession()->SendGMTicketGetTicket(0x0A,0); - - }while(result->NextRow()); - - delete result; - - CharacterDatabase.PExecute("DELETE FROM character_ticket"); + ticketmgr.DeleteAll(); SendSysMessage(LANG_COMMAND_ALLTICKETDELETED); return true; } @@ -2088,32 +2035,27 @@ bool ChatHandler::HandleDelTicketCommand(const char *args) // delticket #num if(num > 0) { - QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_id,guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1); - + QueryResult* result = CharacterDatabase.PQuery("SELECT guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1); if(!result) { PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num); - delete result; SetSentErrorMessage(true); return false; } - Field* fields = result->Fetch(); - - uint32 id = fields[0].GetUInt32(); - uint64 guid = fields[1].GetUInt64(); + uint32 guid = fields[0].GetUInt32(); delete result; - CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE ticket_id = '%u'", id); + ticketmgr.Delete(guid); - // notify players about ticket deleting - if(Player* sender = objmgr.GetPlayer(guid)) + //notify player + if(Player* pl = objmgr.GetPlayer(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER))) { - sender->GetSession()->SendGMTicketGetTicket(0x0A,0); - PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,sender->GetName()); + pl->GetSession()->SendGMTicketGetTicket(0x0A, 0); + PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, pl->GetName()); } else - SendSysMessage(LANG_COMMAND_TICKETDEL); + PSendSysMessage(LANG_COMMAND_TICKETDEL); return true; } @@ -2133,7 +2075,7 @@ bool ChatHandler::HandleDelTicketCommand(const char *args) return false; // delticket $char_name - CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u'",GUID_LOPART(guid)); + ticketmgr.Delete(GUID_LOPART(guid)); // notify players about ticket deleting if(Player* sender = objmgr.GetPlayer(guid)) diff --git a/src/game/Makefile.am b/src/game/Makefile.am index ad3315dac..6a1dc7225 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -103,6 +103,9 @@ libmangosgame_a_SOURCES = \ GameObject.h \ GlobalEvents.cpp \ GlobalEvents.h \ + GMTicketHandler.cpp \ + GMTicketMgr.cpp \ + GMTicketMgr.h \ GossipDef.cpp \ GossipDef.h \ GridDefines.h \ diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 4bdbbd31b..2d77c730f 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -355,189 +355,6 @@ void WorldSession::HandleLogoutCancelOpcode( WorldPacket & /*recv_data*/ ) sLog.outDebug( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" ); } -void WorldSession::SendGMTicketGetTicket(uint32 status, char const* text) -{ - int len = text ? strlen(text) : 0; - WorldPacket data( SMSG_GMTICKET_GETTICKET, (4+len+1+4+2+4+4) ); - data << uint32(status); // standard 0x0A, 0x06 if text present - if(status == 6) - { - data << text; // ticket text - data << uint8(0x7); // ticket category - data << float(0); // time from ticket creation? - data << float(0); // const - data << float(0); // const - data << uint8(0); // const - data << uint8(0); // const - } - SendPacket( &data ); -} - -void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ ) -{ - WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 ); - data << (uint32)time(NULL); - data << (uint32)0; - SendPacket( &data ); - - uint64 guid; - Field *fields; - guid = GetPlayer()->GetGUID(); - - QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(ticket_id) FROM character_ticket WHERE guid = '%u'", GUID_LOPART(guid)); - - if (result) - { - int cnt; - fields = result->Fetch(); - cnt = fields[0].GetUInt32(); - delete result; - - if ( cnt > 0 ) - { - QueryResult *result2 = CharacterDatabase.PQuery("SELECT ticket_text FROM character_ticket WHERE guid = '%u'", GUID_LOPART(guid)); - if(result2) - { - Field *fields2 = result2->Fetch(); - SendGMTicketGetTicket(0x06,fields2[0].GetString()); - delete result2; - } - } - else - SendGMTicketGetTicket(0x0A,0); - } -} - -void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data,1); - - std::string ticketText; - recv_data >> ticketText; - - CharacterDatabase.escape_string(ticketText); - CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", ticketText.c_str(), _player->GetGUIDLow()); -} - -void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/ ) -{ - uint32 guid = GetPlayer()->GetGUIDLow(); - - CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u' LIMIT 1",guid); - - WorldPacket data( SMSG_GMTICKET_DELETETICKET, 4 ); - data << uint32(9); - SendPacket( &data ); - - SendGMTicketGetTicket(0x0A, 0); -} - -void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) -{ - CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4); - - uint32 map; - float x, y, z; - std::string ticketText = ""; - uint32 unk1, unk2; - - recv_data >> map >> x >> y >> z; // last check 2.4.3 - recv_data >> ticketText; - - // recheck - CHECK_PACKET_SIZE(recv_data,4*4+(ticketText.size()+1)+2*4); - - recv_data >> unk1 >> unk2; - // note: the packet might contain more data, but the exact structure of that is unknown - - sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2); - - CharacterDatabase.escape_string(ticketText); - - QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM character_ticket WHERE guid = '%u'", _player->GetGUIDLow()); - - if (result) - { - int cnt; - Field *fields = result->Fetch(); - cnt = fields[0].GetUInt32(); - delete result; - - if ( cnt > 0 ) - { - WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); - data << uint32(1); - SendPacket( &data ); - } - else - { - CharacterDatabase.PExecute("INSERT INTO character_ticket (guid,ticket_text) VALUES ('%u', '%s')", _player->GetGUIDLow(), ticketText.c_str()); - - WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 ); - data << (uint32)time(NULL); - data << (uint32)0; - SendPacket( &data ); - - data.Initialize( SMSG_GMTICKET_CREATE, 4 ); - data << uint32(2); - SendPacket( &data ); - DEBUG_LOG("update the ticket\n"); - - //TODO: Guard player map - HashMapHolder::MapType &m = ObjectAccessor::Instance().GetPlayers(); - for(HashMapHolder::MapType::iterator itr = m.begin(); itr != m.end(); ++itr) - { - if(itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets()) - ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName()); - } - } - } -} - -void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ ) -{ - WorldPacket data( SMSG_GMTICKET_SYSTEMSTATUS,4 ); - data << uint32(1); // we can also disable ticket system by sending 0 value - - SendPacket( &data ); -} - -void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data) -{ - // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3 - CHECK_PACKET_SIZE(recv_data,4+4); - uint32 x; - recv_data >> x; // answer range? (6 = 0-5?) - sLog.outDebug("SURVEY: X = %u", x); - - uint8 result[10]; - memset(result, 0, sizeof(result)); - for( int i = 0; i < 10; ++i) - { - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+4); - uint32 questionID; - recv_data >> questionID; // GMSurveyQuestions.dbc - if (!questionID) - break; - - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1+1); - uint8 value; - std::string unk_text; - recv_data >> value; // answer - recv_data >> unk_text; // always empty? - - result[i] = value; - sLog.outDebug("SURVEY: ID %u, value %u, text %s", questionID, value, unk_text.c_str()); - } - - CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1); - std::string comment; - recv_data >> comment; // addional comment - sLog.outDebug("SURVEY: comment %s", comment.c_str()); - - // TODO: chart this data in some way -} - void WorldSession::HandleTogglePvP( WorldPacket & recv_data ) { // this opcode can be used in two ways: Either set explicit new status or toggle old status diff --git a/src/game/World.cpp b/src/game/World.cpp index 4f9dcb005..817436487 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -56,6 +56,7 @@ #include "CellImpl.h" #include "InstanceSaveMgr.h" #include "WaypointManager.h" +#include "GMTicketMgr.h" #include "Util.h" INSTANTIATE_SINGLETON_1( World ); @@ -1125,6 +1126,9 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading Waypoints..." ); WaypointMgr.Load(); + sLog.outString( "Loading GM tickets..."); + ticketmgr.LoadGMTickets(); + ///- Handle outdated emails (delete/return) sLog.outString( "Returning old mails..." ); objmgr.ReturnOrDeleteOldMails(false); diff --git a/win/VC71/game.vcproj b/win/VC71/game.vcproj index 17ce916a6..f51f1c076 100644 --- a/win/VC71/game.vcproj +++ b/win/VC71/game.vcproj @@ -252,6 +252,9 @@ + + @@ -549,6 +552,12 @@ + + + + diff --git a/win/VC80/game.vcproj b/win/VC80/game.vcproj index b05cb193f..1d3886ce7 100644 --- a/win/VC80/game.vcproj +++ b/win/VC80/game.vcproj @@ -510,6 +510,10 @@ RelativePath="..\..\src\game\GameEvent.h" > + + @@ -906,6 +910,14 @@ RelativePath="..\..\src\game\GameObject.h" > + + + + diff --git a/win/VC90/game.vcproj b/win/VC90/game.vcproj index 8d914b3a7..c84b51832 100644 --- a/win/VC90/game.vcproj +++ b/win/VC90/game.vcproj @@ -511,6 +511,10 @@ RelativePath="..\..\src\game\GameEvent.h" > + + @@ -907,6 +911,14 @@ RelativePath="..\..\src\game\GameObject.h" > + + + + From 3e43600c3b12b1053802072b84876c58e91e29ef Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 3 Nov 2008 18:01:31 +0300 Subject: [PATCH 3/3] Correct check for ACE_BIG_ENDIAN. Warning fixed and code cleanups. --- src/framework/Platform/Define.h | 2 +- src/game/AuctionHouse.cpp | 2 +- src/game/BattleGround.cpp | 2 +- src/game/Guild.h | 4 +-- src/game/ItemHandler.cpp | 6 ++-- src/game/ObjectMgr.h | 2 +- src/game/Player.h | 2 +- src/game/QueryHandler.cpp | 14 ++++---- src/shared/vmap/AABSPTree.h | 54 +++++++++++++++-------------- src/shared/vmap/CoordModelMapping.h | 6 ++-- src/shared/vmap/ModelContainer.h | 7 ++-- src/shared/vmap/VMapDefinitions.h | 4 +-- src/shared/vmap/VMapManager.h | 10 +++--- src/shared/vmap/VMapTools.h | 2 +- 14 files changed, 60 insertions(+), 57 deletions(-) diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index 3f8cc1590..add74f347 100644 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -30,7 +30,7 @@ #define MANGOS_BIGENDIAN 1 #if !defined(MANGOS_ENDIAN) -# if ACE_BYTE_ORDER == ACE_BIG_ENDIAN +# if defined (ACE_BIG_ENDIAN) # define MANGOS_ENDIAN MANGOS_BIGENDIAN # else //ACE_BYTE_ORDER != ACE_BIG_ENDIAN # define MANGOS_ENDIAN MANGOS_LITTLEENDIAN diff --git a/src/game/AuctionHouse.cpp b/src/game/AuctionHouse.cpp index d85bc34bb..61e1377a1 100644 --- a/src/game/AuctionHouse.cpp +++ b/src/game/AuctionHouse.cpp @@ -714,7 +714,7 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data ) ItemLocale const *il = objmgr.GetItemLocale(proto->ItemId); if (il) { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) name = il->Name[loc_idx]; } } diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 00db60b4f..7cb417ce5 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -510,7 +510,7 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex(); if ( loc_idx >= 0 ) if(ItemLocale const *il = objmgr.GetItemLocale(markProto->ItemId)) - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) subject = il->Name[loc_idx]; // text diff --git a/src/game/Guild.h b/src/game/Guild.h index cb46e1107..68a5dc773 100644 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -197,7 +197,7 @@ struct GuildBankEvent uint8 DestTabId; uint64 TimeStamp; - const bool isMoneyEvent() + bool isMoneyEvent() const { return LogEntry == GUILD_BANK_LOG_DEPOSIT_MONEY || LogEntry == GUILD_BANK_LOG_WITHDRAW_MONEY || @@ -356,7 +356,7 @@ class Guild void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); void CreateBankRightForTab(uint32 rankid, uint8 TabId); const GuildBankTab *GetBankTab(uint8 index) { if(index >= m_TabListMap.size()) return NULL; return m_TabListMap[index]; } - const uint8 GetPurchasedTabs() const { return purchased_tabs; } + uint8 GetPurchasedTabs() const { return purchased_tabs; } uint32 GetBankRights(uint32 rankId, uint8 TabId) const; bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index 9396b8633..421f6ae53 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -311,9 +311,9 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data ) ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); if (il) { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) Name = il->Name[loc_idx]; - if (il->Description.size() > loc_idx && !il->Description[loc_idx].empty()) + if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty()) Description = il->Description[loc_idx]; } } @@ -977,7 +977,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); if (il) { - if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) + if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) Name = il->Name[loc_idx]; } } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index c9b4e9bdf..6e0b178ea 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -700,7 +700,7 @@ class ObjectMgr int GetIndexForLocale(LocaleConstant loc); LocaleConstant GetLocaleForIndex(int i); // guild bank tabs - const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } + uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; } uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const diff --git a/src/game/Player.h b/src/game/Player.h index ca6e50bd9..7db254863 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1296,7 +1296,7 @@ class MANGOS_DLL_SPEC Player : public Unit if(d < 0) SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); else - SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); + SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); // "At Gold Limit" if(GetMoney() >= MAX_MONEY_AMOUNT) diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 2c912a9e7..f71cb761b 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -165,9 +165,9 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) CreatureLocale const *cl = objmgr.GetCreatureLocale(entry); if (cl) { - if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty()) + if (cl->Name.size() > size_t(loc_idx) && !cl->Name[loc_idx].empty()) Name = cl->Name[loc_idx]; - if (cl->SubName.size() > loc_idx && !cl->SubName[loc_idx].empty()) + if (cl->SubName.size() > size_t(loc_idx) && !cl->SubName[loc_idx].empty()) SubName = cl->SubName[loc_idx]; } } @@ -233,9 +233,9 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data ) GameObjectLocale const *gl = objmgr.GetGameObjectLocale(entryID); if (gl) { - if (gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) + if (gl->Name.size() > size_t(loc_idx) && !gl->Name[loc_idx].empty()) Name = gl->Name[loc_idx]; - if (gl->CastBarCaption.size() > loc_idx && !gl->CastBarCaption[loc_idx].empty()) + if (gl->CastBarCaption.size() > size_t(loc_idx) && !gl->CastBarCaption[loc_idx].empty()) CastBarCaption = gl->CastBarCaption[loc_idx]; } } @@ -345,9 +345,9 @@ void WorldSession::HandleNpcTextQueryOpcode( WorldPacket & recv_data ) { for (int i=0;i<8;i++) { - if (nl->Text_0[i].size() > loc_idx && !nl->Text_0[i][loc_idx].empty()) + if (nl->Text_0[i].size() > size_t(loc_idx) && !nl->Text_0[i][loc_idx].empty()) Text_0[i]=nl->Text_0[i][loc_idx]; - if (nl->Text_1[i].size() > loc_idx && !nl->Text_1[i][loc_idx].empty()) + if (nl->Text_1[i].size() > size_t(loc_idx) && !nl->Text_1[i][loc_idx].empty()) Text_1[i]=nl->Text_1[i][loc_idx]; } } @@ -417,7 +417,7 @@ void WorldSession::HandlePageQueryOpcode( WorldPacket & recv_data ) PageTextLocale const *pl = objmgr.GetPageTextLocale(pageID); if (pl) { - if (pl->Text.size() > loc_idx && !pl->Text[loc_idx].empty()) + if (pl->Text.size() > size_t(loc_idx) && !pl->Text[loc_idx].empty()) Text = pl->Text[loc_idx]; } } diff --git a/src/shared/vmap/AABSPTree.h b/src/shared/vmap/AABSPTree.h index a05fac9ab..7a5488eb9 100644 --- a/src/shared/vmap/AABSPTree.h +++ b/src/shared/vmap/AABSPTree.h @@ -261,7 +261,7 @@ public: /** Returns the bounds of the sub array. Used by makeNode. */ static AABox computeBounds( - const Array<_AABSPTree::Handle*>& point, + const Array<_AABSPTree::Handle*>& point, int beginIndex, int endIndex) { @@ -770,9 +770,11 @@ public: // Some of the elements in the lt or gt array might really overlap the split location. // Move them as needed. - for (int i = 0; i < lt.size(); ++i) { - const AABox& bounds = lt[i]->bounds; - if ((bounds.low()[splitAxis] <= splitLocation) && (bounds.high()[splitAxis] >= splitLocation)) { + for (int i = 0; i < lt.size(); ++i) + { + const AABox& lt_bounds = lt[i]->bounds; + if ((bounds.low()[splitAxis] <= splitLocation) && (lt_bounds.high()[splitAxis] >= splitLocation)) + { node->valueArray.append(lt[i]); // Remove this element and process the new one that // is swapped in in its place. @@ -780,9 +782,11 @@ public: } } - for (int i = 0; i < gt.size(); ++i) { - const AABox& bounds = gt[i]->bounds; - if ((bounds.low()[splitAxis] <= splitLocation) && (bounds.high()[splitAxis] >= splitLocation)) { + for (int i = 0; i < gt.size(); ++i) + { + const AABox& gt_bounds = gt[i]->bounds; + if ((bounds.low()[splitAxis] <= splitLocation) && (gt_bounds.high()[splitAxis] >= splitLocation)) + { node->valueArray.append(gt[i]); // Remove this element and process the new one that // is swapped in in its place. @@ -819,19 +823,20 @@ public: // Verify that all objects ended up on the correct side of the split. // (i.e., make sure that the Array partition was correct) for (int i = 0; i < lt.size(); ++i) { - const AABox& bounds = lt[i]->bounds; - debugAssert(bounds.high()[splitAxis] < splitLocation); + const AABox& lt_bounds = lt[i]->bounds; + debugAssert(lt_bounds.high()[splitAxis] < splitLocation); } for (int i = 0; i < gt.size(); ++i) { - const AABox& bounds = gt[i]->bounds; - debugAssert(bounds.low()[splitAxis] > splitLocation); + const AABox& gt_bounds = gt[i]->bounds; + debugAssert(gt_bounds.low()[splitAxis] > splitLocation); } - for (int i = 0; i < node->valueArray.size(); ++i) { - const AABox& bounds = node->valueArray[i]->bounds; - debugAssert(bounds.high()[splitAxis] >= splitLocation); - debugAssert(bounds.low()[splitAxis] <= splitLocation); + for (int i = 0; i < node->valueArray.size(); ++i) + { + const AABox& node_bounds = node->valueArray[i]->bounds; + debugAssert(node_bounds.high()[splitAxis] >= splitLocation); + debugAssert(node_bounds.low()[splitAxis] <= splitLocation); } # endif @@ -925,16 +930,17 @@ public: /** Throws out all elements of the set. */ - void clear() { + void clear() + { typedef typename Table<_internal::Indirector<_AABSPTree::Handle >, Node* >::Iterator It; // Delete all handles stored in the member table - It cur = memberTable.begin(); - It end = memberTable.end(); - while (cur != end) { - delete cur->key.handle; - cur->key.handle = NULL; - ++cur; + It tab_cur = memberTable.begin(); + It tab_end = memberTable.end(); + while (tab_cur != tab_end) { + delete tab_cur->key.handle; + tab_cur->key.handle = NULL; + ++tab_cur; } memberTable.clear(); @@ -1543,10 +1549,6 @@ public: private: friend class AABSPTree; - // Note: this is a Table iterator, we are currently defining - // Set iterator - typename Table::Iterator it; - Iterator(const typename Table::Iterator& it) : it(it) {} public: diff --git a/src/shared/vmap/CoordModelMapping.h b/src/shared/vmap/CoordModelMapping.h index f94bcb125..d96107886 100644 --- a/src/shared/vmap/CoordModelMapping.h +++ b/src/shared/vmap/CoordModelMapping.h @@ -126,8 +126,8 @@ namespace VMAP } const G3D::Array& getMaps() const { return iMapIds; } - inline bool isAlreadyProcessedSingleFile(std::string pName) { return(iProcesseSingleFiles.containsKey(pName)); } - inline void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); } + bool isAlreadyProcessedSingleFile(std::string pName) const { return iProcesseSingleFiles.containsKey(pName); } + void addAlreadyProcessedSingleFile(std::string pName) { iProcesseSingleFiles.set(pName,pName); } inline void addWorldAreaMap(unsigned int pMapId) { @@ -136,7 +136,7 @@ namespace VMAP iWorldAreaGroups.append(pMapId); } } - inline bool isWorldAreaMap(unsigned int pMapId) { return(iWorldAreaGroups.contains(pMapId)); } + bool isWorldAreaMap(unsigned int pMapId) const { return(iWorldAreaGroups.contains(pMapId)); } void setModelNameFilterMethod(bool (*pFilterMethod)(char *pName)) { iFilterMethod = pFilterMethod; } }; diff --git a/src/shared/vmap/ModelContainer.h b/src/shared/vmap/ModelContainer.h index edfa3581e..b1a0f1737 100644 --- a/src/shared/vmap/ModelContainer.h +++ b/src/shared/vmap/ModelContainer.h @@ -52,8 +52,9 @@ namespace VMAP SubModel *iSubModel; G3D::AABox iBox; - ModelContainer (const ModelContainer& c): BaseModel(c) {} - ModelContainer& operator=(const ModelContainer& ) {} + // not allowed copy + explicit ModelContainer (const ModelContainer&); + ModelContainer& operator=(const ModelContainer&); public: ModelContainer() : BaseModel() { iNSubModel =0; iSubModel = 0; }; @@ -65,7 +66,7 @@ namespace VMAP ~ModelContainer(void); - inline const void setSubModel(const SubModel& pSubModel, int pPos) { iSubModel[pPos] = pSubModel; } + inline void setSubModel(const SubModel& pSubModel, int pPos) { iSubModel[pPos] = pSubModel; } inline const SubModel& getSubModel(int pPos) const { return iSubModel[pPos]; } diff --git a/src/shared/vmap/VMapDefinitions.h b/src/shared/vmap/VMapDefinitions.h index 4b02d5987..04c31a2b6 100644 --- a/src/shared/vmap/VMapDefinitions.h +++ b/src/shared/vmap/VMapDefinitions.h @@ -23,13 +23,13 @@ namespace VMAP { //===================================== - #define MAX_CAN_FALL_DISTANCE 10.0 + #define MAX_CAN_FALL_DISTANCE 10.0f const char VMAP_MAGIC[] = "VMAP_2.0"; class VMapDefinitions { public: - static const double getMaxCanFallDistance() { return(MAX_CAN_FALL_DISTANCE); } + static float getMaxCanFallDistance() { return MAX_CAN_FALL_DISTANCE; } }; //====================================== diff --git a/src/shared/vmap/VMapManager.h b/src/shared/vmap/VMapManager.h index 54d7a51e3..5e2c32092 100644 --- a/src/shared/vmap/VMapManager.h +++ b/src/shared/vmap/VMapManager.h @@ -88,14 +88,14 @@ namespace VMAP private: float getIntersectionTime(const G3D::Ray& pRay, float pMaxDist, bool pStopAtFirstHit); - bool isAlreadyLoaded(const std::string& pName) { return(iLoadedModelContainer.containsKey(pName)); } + bool isAlreadyLoaded(const std::string& pName) const { return(iLoadedModelContainer.containsKey(pName)); } void setLoadedMapTile(unsigned int pTileIdent) { iLoadedMapTiles.set(pTileIdent, true); } void removeLoadedMapTile(unsigned int pTileIdent) { iLoadedMapTiles.remove(pTileIdent); } - bool hasLoadedMapTiles() { return(iLoadedMapTiles.size() > 0); } - bool containsLoadedMapTile(unsigned int pTileIdent) { return(iLoadedMapTiles.containsKey(pTileIdent)); } + bool hasLoadedMapTiles() const { return iLoadedMapTiles.size() > 0; } + bool containsLoadedMapTile(unsigned int pTileIdent) const { return(iLoadedMapTiles.containsKey(pTileIdent)); } public: ManagedModelContainer *getModelContainer(const std::string& pName) { return(iLoadedModelContainer.get(pName)); } - const bool hasDirFile(const std::string& pDirName) const { return(iLoadedDirFiles.containsKey(pDirName)); } + bool hasDirFile(const std::string& pDirName) const { return(iLoadedDirFiles.containsKey(pDirName)); } FilesInDir& getDirFiles(const std::string& pDirName) const { return(iLoadedDirFiles.get(pDirName)); } public: MapTree(const char *pBasePath); @@ -111,7 +111,7 @@ namespace VMAP void unloadMap(const std::string& dirFileName, unsigned int pMapTileIdent, bool pForce=false); void getModelContainer(G3D::Array& pArray ) { iTree->getMembers(pArray); } - const void addDirFile(const std::string& pDirName, const FilesInDir& pFilesInDir) { iLoadedDirFiles.set(pDirName, pFilesInDir); } + void addDirFile(const std::string& pDirName, const FilesInDir& pFilesInDir) { iLoadedDirFiles.set(pDirName, pFilesInDir); } size_t size() { return(iTree->size()); } }; diff --git a/src/shared/vmap/VMapTools.h b/src/shared/vmap/VMapTools.h index 211940495..4122f420e 100644 --- a/src/shared/vmap/VMapTools.h +++ b/src/shared/vmap/VMapTools.h @@ -62,7 +62,7 @@ namespace VMAP { // Integer representation of a floating-point value. -#define IR(x) ((G3D::uint32&)x) +#define IR(x) (reinterpret_cast(x)) Inside = true; const G3D::Vector3& MinB = box.low();