From: <rds...@us...> - 2008-06-26 07:16:02
|
Revision: 1801 http://planeshift.svn.sourceforge.net/planeshift/?rev=1801&view=rev Author: rdschulz Date: 2008-06-26 00:16:11 -0700 (Thu, 26 Jun 2008) Log Message: ----------- - commit fix to FS#707 by Zwenze - /giveitem and /takeitem now allow to take or give trias as well Modified Paths: -------------- trunk/data/help.xml trunk/docs/history.txt trunk/src/server/adminmanager.cpp Modified: trunk/data/help.xml =================================================================== --- trunk/data/help.xml 2008-06-26 07:04:07 UTC (rev 1800) +++ trunk/data/help.xml 2008-06-26 07:16:11 UTC (rev 1801) @@ -457,7 +457,7 @@ value (in milliseconds). With specified sector, it starts fog with default values: density 200, fade 10 sec, soft white (r 200, g 200, w 200). Use /fog sector off or /fog sector -1 for resetting. </topic> - <topic name="/giveitem">/giveitem [target] [quantity|'all'|''] [item] + <topic name="/giveitem">/giveitem [target] [quantity|'all'|''] [item|tria] Commands used to transfer an item from you to another character. Example: "/giveitem Bob Apple"</topic> <topic name="/impersonate">/impersonate name command message @@ -637,7 +637,7 @@ With specified sector, it starts snow with default values: density 4000 flakes, length 10 minutes and 10 seconds of fade. The maximum number of flakes allowed is 8000. Use /snow sector 0 or /snow sector off for ending the event.</topic> - <topic name="/takeitem">/takeitem [target] [quantity|'all'|''] [item] + <topic name="/takeitem">/takeitem [target] [quantity|'all'|''] [item|tria] Command used to transfer an item to you from another character. Example: "/takeitem target 3 Sabre"</topic> <topic name="/teleport">/teleport <subject> <destination> Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2008-06-26 07:04:07 UTC (rev 1800) +++ trunk/docs/history.txt 2008-06-26 07:16:11 UTC (rev 1801) @@ -4,6 +4,8 @@ becoming undeleteable. - commit fix to FS#215 by phenom - remove /quests command from tab completion - commit fix to FS#686 by Boite - remember selected tab in detail window +- commit fix to FS#707 by Zwenze - /giveitem and /takeitem now allow to take + or give trias as well *** 2008-06-26 by Mike Gist - Work on pslaunch. Modified: trunk/src/server/adminmanager.cpp =================================================================== --- trunk/src/server/adminmanager.cpp 2008-06-26 07:04:07 UTC (rev 1800) +++ trunk/src/server/adminmanager.cpp 2008-06-26 07:16:11 UTC (rev 1801) @@ -2286,7 +2286,7 @@ return; } - sql.AppendFmt("update characters set loc_x=%10.2f, loc_y=%10.2f, loc_z=%10.2f, loc_yrot=%10.2f, loc_sector_id=%u, loc_instance=%d where name='%s'", + sql.AppendFmt("update characters set loc_x=%10.2f, loc_y=%10.2f, loc_z=%10.2f, loc_yrot=%10.2f, loc_sector_id=%u, loc_instance=%u where name='%s'", myPoint.x, myPoint.y, myPoint.z, yRot, mysectorinfo->uid, client->GetActor()->GetInstance(), data.player.GetData()); if (db->CommandPump(sql) != 1) @@ -5968,7 +5968,7 @@ if (data.value == 0 || data.item.IsEmpty()) { - psserver->SendSystemError(me->clientnum, "Syntax: \"/[giveitem|takeitem] [target] [quantity|'all'|''] [item]\""); + psserver->SendSystemError(me->clientnum, "Syntax: \"/[giveitem|takeitem] [target] [quantity|'all'|''] [item|tria]\""); return; } @@ -5982,71 +5982,103 @@ psCharacter* targetchar = target->GetCharacterData(); psCharacter* sourcechar = source->GetCharacterData(); - InventoryTransaction srcTran( &sourcechar->Inventory() ); + //int slot = sourcechar->Inventory().FindItemInTopLevelBulkWithStats(itemstats); size_t slot = sourcechar->Inventory().FindItemStatIndex(itemstats); - if (slot == SIZET_NOT_FOUND) + + if (slot != SIZET_NOT_FOUND) { - psserver->SendSystemError(me->clientnum, "Cannot find any %s in %s's inventory.", - data.item.GetData(), source->GetActor()->GetName() ); - return; - } + InventoryTransaction srcTran( &sourcechar->Inventory() ); + psItem* item; + item = sourcechar->Inventory().RemoveItemIndex(slot,data.value); // data.value is the stack count to move, or -1 + if (!item) + { + Error2("Cannot RemoveItemIndex on slot %zu.\n", slot); + psserver->SendSystemError(me->clientnum, "Cannot remove %s from %s's inventory.", + data.item.GetData(), source->GetActor()->GetName() ); + return; + } + psserver->GetCharManager()->UpdateItemViews(source->GetClientNum()); - psItem* item; - item = sourcechar->Inventory().RemoveItemIndex(slot,data.value); // data.value is the stack count to move, or -1 - if (!item) - { - Error2("Cannot RemoveItemIndex on slot %zu.\n", slot); - psserver->SendSystemError(me->clientnum, "Cannot remove %s from %s's inventory.", - data.item.GetData(), source->GetActor()->GetName() ); - return; - } - psserver->GetCharManager()->UpdateItemViews(source->GetClientNum()); + if (item->GetStackCount() < data.value) + { + psserver->SendSystemError(me->clientnum, "There are only %d, not %d in the stack.", item->GetStackCount(), data.value ); + return; + } - if (item->GetStackCount() < data.value) - { - psserver->SendSystemError(me->clientnum, "There are only %d, not %d in the stack.", item->GetStackCount(), data.value ); - return; - } + bool wasEquipped = item->IsEquipped(); - bool wasEquipped = item->IsEquipped(); + // Now here we handle the target machine + InventoryTransaction trgtTran( &targetchar->Inventory() ); - // Now here we handle the target machine - InventoryTransaction trgtTran( &targetchar->Inventory() ); + if (!targetchar->Inventory().Add(item)) + { + psserver->SendSystemError(me->clientnum, "Target inventory is too full to accept item transfer."); + return; + } + psserver->GetCharManager()->UpdateItemViews(target->GetClientNum()); - if (!targetchar->Inventory().Add(item)) - { - psserver->SendSystemError(me->clientnum, "Target inventory is too full to accept item transfer."); + // Inform the GM doing the transfer + psserver->SendSystemOK(me->clientnum, "%s transferred from %s's %s to %s", + item->GetName(), + source->GetActor()->GetName(), + wasEquipped?"equipment":"inventory", + target->GetActor()->GetName() ); + + // If we're giving to someone else, notify them + if (target->GetClientNum() != me->clientnum) + { + psserver->SendSystemOK(target->GetClientNum(), "You were given %s by GM %s.", + item->GetName(), + source->GetActor()->GetName() ); + } + + // If we're taking from someone else, notify them + if (source->GetClientNum() != me->clientnum) + { + psserver->SendSystemResult(source->GetClientNum(), "%s was taken by GM %s.", + item->GetName(), + target->GetActor()->GetName() ); + } + + trgtTran.Commit(); + srcTran.Commit(); return; } - psserver->GetCharManager()->UpdateItemViews(target->GetClientNum()); - - // Inform the GM doing the transfer - psserver->SendSystemOK(me->clientnum, "%s transferred from %s's %s to %s", - item->GetName(), - source->GetActor()->GetName(), - wasEquipped?"equipment":"inventory", - target->GetActor()->GetName() ); - - // If we're giving to someone else, notify them - if (target->GetClientNum() != me->clientnum) + else if (data.item == "tria") { - psserver->SendSystemOK(target->GetClientNum(), "You were given %s by GM %s.", - item->GetName(), - source->GetActor()->GetName() ); + psMoney srcMoney = sourcechar->Money(); + psMoney targetMoney = targetchar->Money(); + int value = data.value; + if (value == -1) + { + value = srcMoney.GetTotal(); + } + else if (value > srcMoney.GetTotal()) + { + value = srcMoney.GetTotal(); + psserver->SendSystemError(me->clientnum, "Only %d tria taken.",srcMoney.GetTotal()); + } + psMoney transferMoney(0, 0, 0, value); + transferMoney = transferMoney.Normalized(); + sourcechar->SetMoney( srcMoney - transferMoney ); + targetchar->SetMoney( targetMoney + transferMoney ); + // If we're taking from someone else, notify them + if (source->GetClientNum() != me->clientnum) + { + psserver->SendSystemResult(source->GetClientNum(), "%d tria was taken by %s.", + value, + target->GetActor()->GetName() ); + } + return; } - - // If we're taking from someone else, notify them - if (source->GetClientNum() != me->clientnum) + else { - psserver->SendSystemResult(source->GetClientNum(), "%s was taken by GM %s.", - item->GetName(), - target->GetActor()->GetName() ); + psserver->SendSystemError(me->clientnum, "Cannot find any %s in %s's inventory.", + data.item.GetData(), source->GetActor()->GetName() ); + return; } - - trgtTran.Commit(); - srcTran.Commit(); } void AdminManager::FreezeClient(MsgEntry* me, psAdminCmdMessage& msg, AdminCmdData& data, Client* client, Client* target) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |