From: <ma...@us...> - 2011-12-22 21:53:27
|
Revision: 7886 http://planeshift.svn.sourceforge.net/planeshift/?rev=7886&view=rev Author: magodra Date: 2011-12-22 21:53:21 +0000 (Thu, 22 Dec 2011) Log Message: ----------- - Fixed crash where player /dig caused NPC client to crash. Modified Paths: -------------- trunk/src/npcclient/networkmgr.cpp trunk/src/server/database/mysql/sc_npctypes.sql trunk/src/server/npcmanager.cpp trunk/src/server/npcmanager.h trunk/src/server/workmanager.cpp Modified: trunk/src/npcclient/networkmgr.cpp =================================================================== --- trunk/src/npcclient/networkmgr.cpp 2011-12-22 20:16:08 UTC (rev 7885) +++ trunk/src/npcclient/networkmgr.cpp 2011-12-22 21:53:21 UTC (rev 7886) @@ -1085,8 +1085,14 @@ { psNPCWorkDoneMessage msg(me); - NPC* npc = npcclient->FindNPC(msg.npcId); + NPC* npc = npcclient->FindNPC(msg.npcEID); + if (!npc) + { + Error2("Could not find npc(%s) for Got work done.", ShowID(msg.npcEID)); + return; + } + // If he just prospected a mine and its a tribe member if(npc->GetBuffer() == "new mine" && npc->GetTribe()) { Modified: trunk/src/server/database/mysql/sc_npctypes.sql =================================================================== --- trunk/src/server/database/mysql/sc_npctypes.sql 2011-12-22 20:16:08 UTC (rev 7885) +++ trunk/src/server/database/mysql/sc_npctypes.sql 2011-12-22 21:53:21 UTC (rev 7886) @@ -420,8 +420,11 @@ <wander anim="walk" /> <equip item="Rock Pick" slot="righthand" /> <loop iterations="3"> + <navigate anim="walk" /> <dig resource="tribe:buffer" /> <wait anim="stand" duration="10" /> + <!-- Must move since dig in same place is not alloved --> + <locate obj="ownbuffer" static="no" /> </loop> <dequip slot="righthand" /> <locate obj="waypoint" static="no" /> Modified: trunk/src/server/npcmanager.cpp =================================================================== --- trunk/src/server/npcmanager.cpp 2011-12-22 20:16:08 UTC (rev 7885) +++ trunk/src/server/npcmanager.cpp 2011-12-22 21:53:21 UTC (rev 7886) @@ -2607,10 +2607,10 @@ msg.Multicast(superclients,-1,PROX_LIST_ANY_RANGE); } -void NPCManager::WorkDoneNotify(EID npcID, csString reward, csString nick) +void NPCManager::WorkDoneNotify(EID npcEID, csString reward, csString nick) { - Debug3(LOG_NPC, npcID.Unbox(), "NPC(%s) got item %s.\n", ShowID(npcID), reward.GetData()); - psNPCWorkDoneMessage msg(0, npcID, reward.GetData(), nick.GetData()); + Debug3(LOG_NPC, npcEID.Unbox(), "NPC(%s) got item %s.\n", ShowID(npcEID), reward.GetData()); + psNPCWorkDoneMessage msg(0, npcEID, reward.GetData(), nick.GetData()); msg.Multicast(superclients,-1,PROX_LIST_ANY_RANGE); } Modified: trunk/src/server/npcmanager.h =================================================================== --- trunk/src/server/npcmanager.h 2011-12-22 20:16:08 UTC (rev 7885) +++ trunk/src/server/npcmanager.h 2011-12-22 21:53:21 UTC (rev 7886) @@ -146,7 +146,7 @@ csArray<PublishDestination>& GetSuperClients() { return superclients; } /// Inform the npc about the reward granted after a work done - void WorkDoneNotify(EID npcID, csString reward, csString nick); + void WorkDoneNotify(EID npcEID, csString reward, csString nick); /// Send a newly spawned npc to a superclient to manage it. void NewNPCNotify(PID player_id, PID master_id, PID owner_id); Modified: trunk/src/server/workmanager.cpp =================================================================== --- trunk/src/server/workmanager.cpp 2011-12-22 20:16:08 UTC (rev 7885) +++ trunk/src/server/workmanager.cpp 2011-12-22 21:53:21 UTC (rev 7886) @@ -879,8 +879,11 @@ item->SetLoaded(); // Item is fully created item->Save(false); // First save - // Inform the npcclient about the item it's npc just got - psserver->GetNPCManager()->WorkDoneNotify(workEvent->worker->GetEID(), newitem->GetName(), resourceNick); + if (!workEvent->client) + { + // Inform the npcclient about the item it's npc just got + psserver->GetNPCManager()->WorkDoneNotify(workEvent->worker->GetEID(), newitem->GetName(), resourceNick); + } // No matter if the item could be moved to inventory reset the last position and // give out skills. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |