From: <wel...@us...> - 2008-12-26 22:00:31
|
Revision: 2782 http://planeshift.svn.sourceforge.net/planeshift/?rev=2782&view=rev Author: weltall2 Date: 2008-12-26 22:00:27 +0000 (Fri, 26 Dec 2008) Log Message: ----------- Committed a patch for additional requests in FS#2340 - Drop Command (inplace command) by kougaro Modified Paths: -------------- trunk/data/help.xml trunk/src/client/cmdusers.cpp trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h trunk/src/server/bulkobjects/pscharacter.cpp trunk/src/server/bulkobjects/pscharacter.h trunk/src/server/slotmanager.cpp Modified: trunk/data/help.xml =================================================================== --- trunk/data/help.xml 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/data/help.xml 2008-12-26 22:00:27 UTC (rev 2782) @@ -103,12 +103,13 @@ <topic name="/dig">/dig for resource Mine for natural resources in the ground. For example: /dig for gold. Some locations are better than others for digging, and how well you do depends on where you are, your skill and your tools.</topic> - <topic name="/drop">/drop quantity|all (any) (noguard) item_name + <topic name="/drop">/drop [quantity|all] (any) (noguard) (inplace) item_name Drop the specified quantity of a certain item from your inventory. example : /drop 15 apple "all" will try and drop all items of this kind available, in the limit of 65 items. The "any" flag allows the function to search for items in containers. -The "noguard" flag will allow you to drop unguarded items</topic> +The "noguard" flag allows you to drop unguarded items. +The "inplace" flag allows you to drop items at your current position.</topic> <topic name="/equip">/equip quantity item_name Equips the specified quantity of a certain item. This is equivalent to equipping items in your Inventory Window.</topic> Modified: trunk/src/client/cmdusers.cpp =================================================================== --- trunk/src/client/cmdusers.cpp 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/src/client/cmdusers.cpp 2008-12-26 22:00:27 UTC (rev 2782) @@ -693,53 +693,64 @@ } else if (words[0] == "/drop") { - if (words.GetCount() < 3) - return "Usage: /drop [quantity] (any) (noguard) [item name]"; - int quantity = atoi(words[1]); + if (words.GetCount() < 2) + return "Usage: /drop [quantity] (any) (noguard) (inplace) [item name]"; + int quantity; csString itemName; bool any = false; bool guard = true; + bool inplace = false; int moneySlot = 0; - if (words[1] == "all") + + unsigned int i = 1; + + if (quantity = atoi(words[1])) { + i++; + } + else if (words[1] == "all") + { quantity = 65; + i++; } + else + { + quantity = 1; + } - if ( words[2] == "tria" || (words[2] == "hexa" && (moneySlot=1)) || - (words[2] == "octa" && (moneySlot=2)) || (words[2] == "circle" && (moneySlot=3)) ) + + if(words[i] == "any") { + i++; + any = true; + } + + if(words[i] == "noguard") + { + i++; + guard = false; + } + + if(words[i] == "inplace") + { + i++; + inplace = true; + } + + if ( words[i] == "tria" || (words[i] == "hexa" && (moneySlot=1)) || + (words[i] == "octa" && (moneySlot=2)) || (words[i] == "circle" && (moneySlot=3)) ) + { psSlotMovementMsg moneydropmsg( CONTAINER_INVENTORY_MONEY, moneySlot, - CONTAINER_WORLD, 0, quantity ); + CONTAINER_WORLD, 0, quantity, 0, guard, inplace ); moneydropmsg.SendMessage(); return NULL; } - else if (words[2] == "any") - { - any = true; - if(words[3] == "noguard") - { - guard = false; - itemName = words.GetTail(4); - } - else - { - itemName = words.GetTail(3); - } - } else { - if(words[2] == "noguard") - { - guard = false; - itemName = words.GetTail(3); - } - else - { - itemName = words.GetTail(2); - } + itemName = words.GetTail(i); + psCmdDropMessage cmddrop(quantity, itemName, any, guard, inplace); + cmddrop.SendMessage(); } - psCmdDropMessage cmddrop(quantity, itemName, any, guard); - cmddrop.SendMessage(); } else if(words[0] == "/emote") { Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/src/common/net/messages.cpp 2008-12-26 22:00:27 UTC (rev 2782) @@ -4921,15 +4921,16 @@ PSF_IMPLEMENT_MSG_FACTORY(psCmdDropMessage,MSGTYPE_CMDDROP); -psCmdDropMessage::psCmdDropMessage( int quantity, csString &itemName, bool container, bool guarded) +psCmdDropMessage::psCmdDropMessage( int quantity, csString &itemName, bool container, bool guarded, bool inplace) { - msg.AttachNew(new MsgEntry( sizeof( int32_t ) + itemName.Length() + sizeof(bool)*2 + 1 )); + msg.AttachNew(new MsgEntry( sizeof( int32_t ) + itemName.Length() + sizeof(bool)*3 + 1 )); msg->SetType(MSGTYPE_CMDDROP); msg->Add( (int32_t) quantity ); msg->Add( itemName ); msg->Add( container ); msg->Add( guarded ); + msg->Add(inplace); } psCmdDropMessage::psCmdDropMessage( MsgEntry* me ) @@ -4938,6 +4939,7 @@ itemName = me->GetStr(); container = me->GetBool(); guarded = me->GetBool(); + inplace = me->GetBool(); } csString psCmdDropMessage::ToString(AccessPointers * /*access_ptrs*/) Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/src/common/net/messages.h 2008-12-26 22:00:27 UTC (rev 2782) @@ -3379,9 +3379,11 @@ int toContainerID, int toSlotID, int stackCount, - csVector3 *pt3d=NULL) + csVector3 *pt3d=NULL, + bool guarded=true, + bool inplace=true) { - msg.AttachNew(new MsgEntry( sizeof( int32_t ) * 5 + 3 * sizeof(float) )); + msg.AttachNew(new MsgEntry( sizeof( int32_t ) * 5 + 3 * sizeof(float) + 2 * sizeof(bool) )); msg->SetType(MSGTYPE_SLOT_MOVEMENT); msg->clientnum = 0; @@ -3398,6 +3400,9 @@ csVector3 v = 0; msg->Add(v); // add dummy zeroes if not specified. } + msg->Add( guarded ); + msg->Add( inplace ); + } psSlotMovementMsg( MsgEntry* me ) @@ -3408,6 +3413,9 @@ toSlot = me->GetInt32(); stackCount = me->GetInt32(); posWorld = me->GetVector(); + guarded = me->GetBool(); + inplace = me->GetBool(); + } PSF_DECLARE_MSG_FACTORY(); @@ -3426,12 +3434,14 @@ int toSlot; int stackCount; csVector3 posWorld; + bool guarded; + bool inplace; }; class psCmdDropMessage : public psMessageCracker { public: - psCmdDropMessage( int quantity, csString &itemName, bool container, bool guarded); + psCmdDropMessage( int quantity, csString &itemName, bool container, bool guarded, bool inplace); psCmdDropMessage( MsgEntry* me ); PSF_DECLARE_MSG_FACTORY(); @@ -3449,6 +3459,7 @@ bool container; bool guarded; + bool inplace; }; class psQuestionCancelMessage : public psMessageCracker Modified: trunk/src/server/bulkobjects/pscharacter.cpp =================================================================== --- trunk/src/server/bulkobjects/pscharacter.cpp 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/src/server/bulkobjects/pscharacter.cpp 2008-12-26 22:00:27 UTC (rev 2782) @@ -1380,7 +1380,7 @@ return CacheManager::GetSingleton().stances.Get(ID); } -void psCharacter::DropItem(psItem *&item, csVector3 suggestedPos, bool guarded, bool transient) +void psCharacter::DropItem(psItem *&item, csVector3 suggestedPos, bool guarded, bool transient, bool inplace) { if (!item) return; @@ -1406,13 +1406,19 @@ suggestedPos = 0; } - if (suggestedPos == 0) + if (suggestedPos == 0 && !inplace) { // No position specified or it was invalid. suggestedPos.x = location.loc.x - (DROP_DISTANCE * sinf(location.loc_yrot)); suggestedPos.y = location.loc.y; suggestedPos.z = location.loc.z - (DROP_DISTANCE * cosf(location.loc_yrot)); } + else if (inplace) + { + suggestedPos.x = location.loc.x; + suggestedPos.y = location.loc.y; + suggestedPos.z = location.loc.z; + } // Play the drop item sound for this item psserver->GetCharManager()->SendOutPlaySoundMessage(actor->GetClientID(), item->GetSound(), "drop"); Modified: trunk/src/server/bulkobjects/pscharacter.h =================================================================== --- trunk/src/server/bulkobjects/pscharacter.h 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/src/server/bulkobjects/pscharacter.h 2008-12-26 22:00:27 UTC (rev 2782) @@ -897,7 +897,7 @@ * @param Item to be dropped * @param Transient flag (decay?) (default=true) */ - void DropItem(psItem *&item, csVector3 pos = 0, bool guarded = true, bool transient = true); + void DropItem(psItem *&item, csVector3 pos = 0, bool guarded = true, bool transient = true, bool inplace = false); float AdjustHitPoints(float adjust); float AdjustHitPointsMax(float adjust); Modified: trunk/src/server/slotmanager.cpp =================================================================== --- trunk/src/server/slotmanager.cpp 2008-12-26 19:08:28 UTC (rev 2781) +++ trunk/src/server/slotmanager.cpp 2008-12-26 22:00:27 UTC (rev 2782) @@ -343,7 +343,6 @@ psMoney money; money.Adjust(msg.fromSlot, msg.stackCount); - switch (msg.toContainer) { case CONTAINER_WORLD: @@ -360,7 +359,7 @@ // Remove the money from inventory, and put in world. money.Set(-money.Get(3), -money.Get(2), -money.Get(1), -money.Get(0)); chr->AdjustMoney(money, false); - chr->DropItem(item, msg.posWorld); + chr->DropItem(item, msg.posWorld, msg.guarded, true, msg.inplace); } else Error3("Could not create money item from slot %d, count %d!", msg.fromSlot, msg.stackCount); @@ -978,7 +977,7 @@ } psItem* toDropItem = chr->Inventory().RemoveItemID(stackItem->GetUID(), removeCount); - chr->DropItem(toDropItem, 0, mesg.guarded); + chr->DropItem(toDropItem, 0, mesg.guarded, true, mesg.inplace); psserver->GetCharManager()->UpdateItemViews(fromClient->GetClientNum()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |