From: <Kha...@us...> - 2009-12-31 17:35:49
|
Revision: 5120 http://planeshift.svn.sourceforge.net/planeshift/?rev=5120&view=rev Author: Khakilord Date: 2009-12-31 17:35:41 +0000 (Thu, 31 Dec 2009) Log Message: ----------- Limited rate of sending glyph lists to the client to once every 0.25 seconds. Modified Paths: -------------- trunk/src/server/client.cpp trunk/src/server/client.h trunk/src/server/command.cpp trunk/src/server/psserverchar.cpp trunk/src/server/slotmanager.cpp trunk/src/server/spellmanager.cpp trunk/src/server/spellmanager.h Modified: trunk/src/server/client.cpp =================================================================== --- trunk/src/server/client.cpp 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/client.cpp 2009-12-31 17:35:41 UTC (rev 5120) @@ -71,6 +71,7 @@ nextFloodHistoryIndex = 0; lastInventorySend = 0; + lastGlyphSend = 0; isAdvisor = false; isFrozen = false; Modified: trunk/src/server/client.h =================================================================== --- trunk/src/server/client.h 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/client.h 2009-12-31 17:35:41 UTC (rev 5120) @@ -366,9 +366,10 @@ OrderedMessageChannel * GetOrderedMessageChannel(msgtype mtype); // FIXME: Ugly hack here as a temporary workaround for client-side issue that causes the server - // to be flooded with inventory requests. Remove after all clients have been updated + // to be flooded with inventory/glyph requests. Remove after all clients have been updated // to stop flooding. csTicks lastInventorySend; + csTicks lastGlyphSend; protected: Modified: trunk/src/server/command.cpp =================================================================== --- trunk/src/server/command.cpp 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/command.cpp 2009-12-31 17:35:41 UTC (rev 5120) @@ -355,7 +355,7 @@ } if(client->GetConnection()) { - clientStatus.AppendFmt(" %u %u %g %u", client->GetConnection()->RTO, + clientStatus.AppendFmt(" %4u %4u %4.2f %4u", client->GetConnection()->RTO, client->GetConnection()->window, client->GetConnection()->sends > 0 ? 100.0 * client->GetConnection()->resends/client->GetConnection()->sends : 0.0, client->GetConnection()->sends); } clientStatus.Append('\n'); Modified: trunk/src/server/psserverchar.cpp =================================================================== --- trunk/src/server/psserverchar.cpp 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/psserverchar.cpp 2009-12-31 17:35:41 UTC (rev 5120) @@ -367,7 +367,7 @@ } else { - status.Format("Ignored inventory request message."); + status.Format("Ignored inventory request message from %u.", client->GetClientNum()); if(LogCSV::GetSingletonPtr()) LogCSV::GetSingleton().Write(CSV_STATUS, status); } Modified: trunk/src/server/slotmanager.cpp =================================================================== --- trunk/src/server/slotmanager.cpp 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/slotmanager.cpp 2009-12-31 17:35:41 UTC (rev 5120) @@ -122,12 +122,7 @@ // also it updates glyphs as well if(!(mesg.fromContainer == mesg.toContainer && mesg.fromSlot == mesg.toSlot && mesg.posWorld.IsZero())) { - csString status; - status.Format("Received slot movement message. Client %u Container %d to %d Slot %d to %d stack %d pos %g %g %g", fromClient->GetClientNum(), mesg.fromContainer, mesg.toContainer, mesg.fromSlot, mesg.toSlot, mesg.stackCount, mesg.posWorld.x, mesg.posWorld.y, mesg.posWorld.z); - - if(LogCSV::GetSingletonPtr()) - LogCSV::GetSingleton().Write(CSV_STATUS, status); - if(worldContainerID == 0 || otherContainerID <= 100) + if(worldContainerID == 0 || otherContainerID <= 100) psserver->GetCharManager()->UpdateItemViews(fromClient->GetClientNum()); } else Modified: trunk/src/server/spellmanager.cpp =================================================================== --- trunk/src/server/spellmanager.cpp 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/spellmanager.cpp 2009-12-31 17:35:41 UTC (rev 5120) @@ -78,7 +78,7 @@ clients = ccs; this->object_reg = object_reg; - psserver->GetEventManager()->Subscribe(this,new NetMessageCallback<SpellManager>(this,&SpellManager::SendGlyphs),MSGTYPE_GLYPH_REQUEST,REQUIRE_READY_CLIENT|REQUIRE_ALIVE); + psserver->GetEventManager()->Subscribe(this,new NetMessageCallback<SpellManager>(this,&SpellManager::HandleGlyphRequest),MSGTYPE_GLYPH_REQUEST,REQUIRE_READY_CLIENT|REQUIRE_ALIVE); psserver->GetEventManager()->Subscribe(this,new NetMessageCallback<SpellManager>(this,&SpellManager::HandleAssembler),MSGTYPE_GLYPH_ASSEMBLE,REQUIRE_READY_CLIENT|REQUIRE_ALIVE); psserver->GetEventManager()->Subscribe(this,new NetMessageCallback<SpellManager>(this,&SpellManager::Cast),MSGTYPE_SPELL_CAST,REQUIRE_READY_CLIENT|REQUIRE_ALIVE); psserver->GetEventManager()->Subscribe(this,new NetMessageCallback<SpellManager>(this,&SpellManager::StartPurifying),MSGTYPE_PURIFY_GLYPH,REQUIRE_READY_CLIENT|REQUIRE_ALIVE); @@ -275,6 +275,27 @@ mesg.SendMessage(); } +void SpellManager::HandleGlyphRequest(MsgEntry *notused, Client * client) +{ + // FIXME: Ugly hack here as a temporary workaround for client-side issue that causes the server + // to be flooded with glyph requests. Remove after all clients have been updated + // to stop flooding. + csTicks currentTime = csGetTicks(); + // Send a glyph message maximum once per 250 ticks (0.25 seconds). + if(!client->lastGlyphSend || client->lastGlyphSend + 250 < currentTime) + { + client->lastGlyphSend = currentTime; + SendGlyphs(notused, client); + } + else + { + csString status; + status.Format("Ignored glyph request message from %u.", client->GetClientNum()); + if(LogCSV::GetSingletonPtr()) + LogCSV::GetSingleton().Write(CSV_STATUS, status); + } +} + void SpellManager::SendGlyphs(MsgEntry *notused, Client * client) { psCharacter * character = client->GetCharacterData(); Modified: trunk/src/server/spellmanager.h =================================================================== --- trunk/src/server/spellmanager.h 2009-12-31 11:47:03 UTC (rev 5119) +++ trunk/src/server/spellmanager.h 2009-12-31 17:35:41 UTC (rev 5120) @@ -77,6 +77,11 @@ * @param client The client that will be sent it's current glyphs. */ void SendGlyphs(MsgEntry *notused, Client * client); + + /** Handles a glyph request from a client. + * + */ + void HandleGlyphRequest(MsgEntry *notused, Client * client); protected: /** Save a spell to the database for when a player has researched it. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |