[svn] DynamicObject should only be visible for caster if it is not in distance. However, I do not think this will fix the bug that dynamic object update freezes the server.

--HG--
branch : trunk
This commit is contained in:
megamage
2008-11-15 11:56:59 -06:00
parent 9ff33852b7
commit 8df6868fac
7 changed files with 56 additions and 53 deletions
+6 -4
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "Common.h" #include "Common.h"
@@ -70,7 +70,7 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
return false; return false;
} }
SetUInt32Value( OBJECT_FIELD_ENTRY, spellId ); SetEntry(spellId);
SetFloatValue( OBJECT_FIELD_SCALE_X, 1 ); SetFloatValue( OBJECT_FIELD_SCALE_X, 1 );
SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() ); SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() );
SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 ); SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 );
@@ -153,5 +153,7 @@ void DynamicObject::Delay(int32 delaytime)
bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const bool DynamicObject::isVisibleForInState(Player const* u, bool inVisibleList) const
{ {
return IsInWorld() && u->IsInWorld() /*&& IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))*/; return IsInWorld() && u->IsInWorld()
&& (IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))
|| GetCasterGUID() == u->GetGUID());
} }
+2 -3
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
@@ -612,7 +612,6 @@ ObjectAccessor::ActiveObjectsNearGrid(uint32 x, uint32 y, uint32 m_id, uint32 i_
if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )
return true; return true;
} }
return false; return false;
+24 -21
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/// \addtogroup Trinityd /// \addtogroup Trinityd
@@ -51,7 +51,7 @@ void utf8print(const char* str)
CharToOemBuffW(&wtemp_buf[0],&temp_buf[0],wtemp_len+1); CharToOemBuffW(&wtemp_buf[0],&temp_buf[0],wtemp_len+1);
printf(temp_buf); printf(temp_buf);
#else #else
printf(str); printf(str);
#endif #endif
} }
@@ -118,7 +118,7 @@ bool ChatHandler::HandleAccountDeleteCommand(const char* args)
return false; return false;
} }
return true; return true;
} }
bool ChatHandler::HandleCharacterDeleteCommand(const char* args) bool ChatHandler::HandleCharacterDeleteCommand(const char* args)
@@ -126,18 +126,18 @@ bool ChatHandler::HandleCharacterDeleteCommand(const char* args)
if(!*args) if(!*args)
return false; return false;
char *character_name_str = strtok((char*)args," "); char *character_name_str = strtok((char*)args," ");
if(!character_name_str) if(!character_name_str)
return false; return false;
std::string character_name = character_name_str; std::string character_name = character_name_str;
if(!normalizePlayerName(character_name)) if(!normalizePlayerName(character_name))
return false; return false;
uint64 character_guid; uint64 character_guid;
uint32 account_id; uint32 account_id;
Player *player = objmgr.GetPlayer(character_name.c_str()); Player *player = objmgr.GetPlayer(character_name.c_str());
if(player) if(player)
{ {
character_guid = player->GetGUID(); character_guid = player->GetGUID();
@@ -157,10 +157,10 @@ bool ChatHandler::HandleCharacterDeleteCommand(const char* args)
account_id = objmgr.GetPlayerAccountIdByGUID(character_guid); account_id = objmgr.GetPlayerAccountIdByGUID(character_guid);
} }
std::string account_name; std::string account_name;
accmgr.GetName (account_id,account_name); accmgr.GetName (account_id,account_name);
Player::DeleteFromDB(character_guid, account_id, true); Player::DeleteFromDB(character_guid, account_id, true);
PSendSysMessage(LANG_CHARACTER_DELETED,character_name.c_str(),GUID_LOPART(character_guid),account_name.c_str(), account_id); PSendSysMessage(LANG_CHARACTER_DELETED,character_name.c_str(),GUID_LOPART(character_guid),account_name.c_str(), account_id);
return true; return true;
} }
@@ -170,7 +170,7 @@ bool ChatHandler::HandleServerExitCommand(const char* args)
{ {
SendSysMessage(LANG_COMMAND_EXIT); SendSysMessage(LANG_COMMAND_EXIT);
World::m_stopEvent = true; World::m_stopEvent = true;
return true; return true;
} }
/// Display info on users currently in the realm /// Display info on users currently in the realm
@@ -227,7 +227,7 @@ bool ChatHandler::HandleAccountCreateCommand(const char* args)
char *szAcc = strtok((char*)args, " "); char *szAcc = strtok((char*)args, " ");
char *szPassword = strtok(NULL, " "); char *szPassword = strtok(NULL, " ");
if(!szAcc || !szPassword) if(!szAcc || !szPassword)
return false; return false;
// normilized in accmgr.CreateAccount // normilized in accmgr.CreateAccount
std::string account_name = szAcc; std::string account_name = szAcc;
@@ -256,8 +256,8 @@ bool ChatHandler::HandleAccountCreateCommand(const char* args)
SetSentErrorMessage(true); SetSentErrorMessage(true);
return false; return false;
} }
return true; return true;
} }
/// Set the level of logging /// Set the level of logging
@@ -268,10 +268,10 @@ bool ChatHandler::HandleServerSetLogLevelCommand(const char *args)
char *NewLevel = strtok((char*)args, " "); char *NewLevel = strtok((char*)args, " ");
if (!NewLevel) if (!NewLevel)
return false; return false;
sLog.SetLogLevel(NewLevel); sLog.SetLogLevel(NewLevel);
return true; return true;
} }
/// @} /// @}
@@ -325,12 +325,13 @@ void CliRunnable::run()
{ {
for(int x=0;command_str[x];x++) for(int x=0;command_str[x];x++)
if(command_str[x]=='\r'||command_str[x]=='\n') if(command_str[x]=='\r'||command_str[x]=='\n')
{ {
command_str[x]=0; command_str[x]=0;
break; break;
} }
if(!*command_str)
if(!*command_str)
{ {
printf("TC>"); printf("TC>");
continue; continue;
@@ -346,7 +347,9 @@ void CliRunnable::run()
sWorld.QueueCliCommand(&utf8print,command.c_str()); sWorld.QueueCliCommand(&utf8print,command.c_str());
} }
else if (feof(stdin)) else if (feof(stdin))
{
World::m_stopEvent = true; World::m_stopEvent = true;
}
} }
///- End the database thread ///- End the database thread
+2 -3
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/// \addtogroup Trinityd Trinity Daemon /// \addtogroup Trinityd Trinity Daemon
@@ -137,7 +137,6 @@ extern int main(int argc, char **argv)
sLog.outError("Could not find configuration file %s.", cfg_file); sLog.outError("Could not find configuration file %s.", cfg_file);
return 1; return 1;
} }
sLog.outString("Using configuration file %s.", cfg_file); sLog.outString("Using configuration file %s.", cfg_file);
uint32 confVersion = sConfig.GetIntDefault("ConfVersion", 0); uint32 confVersion = sConfig.GetIntDefault("ConfVersion", 0);
+11 -11
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/** \file /** \file
@@ -83,15 +83,15 @@ public:
uint32 curtime = getMSTime(); uint32 curtime = getMSTime();
//DEBUG_LOG("anti-freeze: time=%u, counters=[%u; %u]",curtime,Master::m_masterLoopCounter,World::m_worldLoopCounter); //DEBUG_LOG("anti-freeze: time=%u, counters=[%u; %u]",curtime,Master::m_masterLoopCounter,World::m_worldLoopCounter);
// There is no Master anymore // There is no Master anymore
// TODO: clear the rest of the code // TODO: clear the rest of the code
// // normal work // // normal work
// if(m_loops != Master::m_masterLoopCounter) // if(m_loops != Master::m_masterLoopCounter)
// { // {
// m_lastchange = curtime; // m_lastchange = curtime;
// m_loops = Master::m_masterLoopCounter; // m_loops = Master::m_masterLoopCounter;
// } // }
// // possible freeze // // possible freeze
// else if(getMSTimeDiff(m_lastchange,curtime) > _delaytime) // else if(getMSTimeDiff(m_lastchange,curtime) > _delaytime)
// { // {
// sLog.outError("Main/Sockets Thread hangs, kicking out server!"); // sLog.outError("Main/Sockets Thread hangs, kicking out server!");
@@ -104,7 +104,7 @@ public:
w_lastchange = curtime; w_lastchange = curtime;
w_loops = World::m_worldLoopCounter; w_loops = World::m_worldLoopCounter;
} }
// possible freeze // possible freeze
else if(getMSTimeDiff(w_lastchange,curtime) > _delaytime) else if(getMSTimeDiff(w_lastchange,curtime) > _delaytime)
{ {
sLog.outError("World Thread hangs, kicking out server!"); sLog.outError("World Thread hangs, kicking out server!");
@@ -250,7 +250,7 @@ int Master::Run()
///- Launch CliRunnable thread ///- Launch CliRunnable thread
ZThread::Thread td1(new CliRunnable); ZThread::Thread td1(new CliRunnable);
} }
ZThread::Thread td2(new RARunnable); ZThread::Thread td2(new RARunnable);
///- Handle affinity for multiple processors and process priority on Windows ///- Handle affinity for multiple processors and process priority on Windows
@@ -328,7 +328,7 @@ int Master::Run()
} }
sWorldSocketMgr->Wait (); sWorldSocketMgr->Wait ();
// set server offline // set server offline
loginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID); loginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
@@ -339,7 +339,7 @@ int Master::Run()
// since worldrunnable uses them, it will crash if unloaded after master // since worldrunnable uses them, it will crash if unloaded after master
t.wait(); t.wait();
td2.wait (); td2.wait ();
///- Clean database before leaving ///- Clean database before leaving
clearOnlineAccounts(); clearOnlineAccounts();
@@ -459,7 +459,7 @@ bool Master::_StartDB()
sWorld.LoadDBVersion(); sWorld.LoadDBVersion();
sLog.outString("Using %s", sWorld.GetDBVersion()); sLog.outString("Using %s", sWorld.GetDBVersion());
return true; return true;
} }
@@ -471,7 +471,7 @@ void Master::clearOnlineAccounts()
loginDatabase.PExecute( loginDatabase.PExecute(
"UPDATE account SET online = 0 WHERE online > 0 " "UPDATE account SET online = 0 WHERE online > 0 "
"AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID); "AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID);
CharacterDatabase.Execute("UPDATE characters SET online = 0"); CharacterDatabase.Execute("UPDATE characters SET online = 0");
} }
+8 -8
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/** \file /** \file
@@ -197,8 +197,8 @@ void RASocket::OnRead()
loginDatabase.escape_string(pw); loginDatabase.escape_string(pw);
QueryResult *check = loginDatabase.PQuery( QueryResult *check = loginDatabase.PQuery(
"SELECT 1 FROM account WHERE username = '%s' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))", "SELECT 1 FROM account WHERE username = '%s' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))",
login.c_str(), pw.c_str()); login.c_str(), pw.c_str());
if(check) if(check)
{ {
@@ -244,13 +244,13 @@ void RASocket::zprint( const char * szText )
#ifdef RA_CRYPT #ifdef RA_CRYPT
char *megabuffer=strdup(szText); char *megabuffer=strdup(szText);
unsigned int sz=strlen(megabuffer); unsigned int sz=strlen(megabuffer);
Encrypt(megabuffer,sz); Encrypt(megabuffer,sz);
send(r,megabuffer,sz,0); send(r,megabuffer,sz,0);
delete [] megabuffer; delete [] megabuffer;
#else #else
unsigned int sz=strlen(szText); unsigned int sz=strlen(szText);
send(r,szText,sz,0); send(r,szText,sz,0);
+3 -3
View File
@@ -10,12 +10,12 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/** \file /** \file
@@ -77,7 +77,7 @@ void WorldRunnable::run()
sWorld.KickAllQueued(); // kick all queued players (and prevent its login at kick in game players) sWorld.KickAllQueued(); // kick all queued players (and prevent its login at kick in game players)
sWorld.KickAll(); // save and kick all players sWorld.KickAll(); // save and kick all players
sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call
sWorldSocketMgr->StopNetwork(); sWorldSocketMgr->StopNetwork();
MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory) MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory)