Permalink
Browse files

add item worth to lookat, remove lookat for old menus

  • Loading branch information...
1 parent 360c016 commit 36f1009771613d53c217dd3cbdea70b8665c8eb5 @vilarion vilarion committed Apr 30, 2012
View
@@ -131,6 +131,16 @@ bool Item::isContainer() const {
return ContainerItems->find(id);
}
+TYPE_OF_WORTH Item::getWorth() const {
+ CommonStruct common;
+
+ if (CommonItems->find(id, common)) {
+ return common.Worth;
+ }
+
+ return 0;
+}
+
bool Item::isComplete() const {
return quality >= 100;
}
View
@@ -114,6 +114,7 @@ class Item {
bool survivesAging();
bool isContainer() const;
+ TYPE_OF_WORTH getWorth() const;
bool isComplete() const;
bool isPermanent() const;
void makePermanent();
View
@@ -984,12 +984,6 @@ class World {
// \param position die Position des Item im showcase
void lookAtShowcaseItem(Player *cp, unsigned char showcase, unsigned char position);
- //! sendet an den Spieler den Namen des Item an einer Position im Men
- // \param cp der Spieler der benachrichtigt werden soll
- // \param position die Position des Item im showcase
- // \param itemid ID des Item
- void lookAtMenueItem(Player *cp, unsigned char position, unsigned short int itemid);
-
//! sendet an den Spieler den Namen des Item an einer Position im Inventory
// \param cp der Spieler der benachrichtigt werden soll
// \param position die Position des Item im Inventory
View
@@ -236,12 +236,12 @@ void World::ItemInform(Character *user, ScriptItem item, std::string message) {
showcase = 1;
}
- boost::shared_ptr<BasicServerCommand>cmd(new NameOfShowCaseItemTC(showcase, item.itempos, message));
+ boost::shared_ptr<BasicServerCommand>cmd(new NameOfShowCaseItemTC(showcase, item.itempos, message, item.getWorth()));
cp->Connection->addCommand(cmd);
}
} else if (item.type == ScriptItem::it_inventory || item.type == ScriptItem::it_belt) {
if (item.owner->character == Character::player) {
- boost::shared_ptr<BasicServerCommand>cmd(new NameOfInventoryItemTC(item.itempos, message));
+ boost::shared_ptr<BasicServerCommand>cmd(new NameOfInventoryItemTC(item.itempos, message, item.getWorth()));
cp->Connection->addCommand(cmd);
}
} else if (item.type == ScriptItem::it_field) {
View
@@ -454,42 +454,6 @@ void World::lookAtMapItem(Player *cp, short int x, short int y, short int z) {
}
-void World::lookAtMenueItem(Player *cp, unsigned char position, TYPE_OF_ITEM_ID itemid) {
- std::string name="";
-
- if (ItemNames->find(itemid, tempNames)) { // Namen f�r das Item gefunden
- switch (cp->getPlayerLanguage()) {
- case Language::german:
- name = tempNames.German;
- break;
- case Language::english:
- name = tempNames.English;
- break;
- default:
- name = std::string("unknown mother tongue");
- break;
- }
- } else {
- // kein Name vorhanden
- switch (cp->getPlayerLanguage()) {
- case Language::german:
- name = std::string("unbekannt");
- break;
- case Language::english:
- name = std::string("unknown");
- break;
- default:
- name = std::string("?");
- break;
- }
- }
-
- boost::shared_ptr<BasicServerCommand>cmd(new NameOfShowCaseItemTC(2, position,name));
- cp->Connection->addCommand(cmd);
-}
-
-
-
void World::lookAtShowcaseItem(Player *cp, unsigned char showcase, unsigned char position) {
ScriptItem titem;
@@ -557,7 +521,7 @@ void World::lookAtShowcaseItem(Player *cp, unsigned char showcase, unsigned char
}
}
- boost::shared_ptr<BasicServerCommand>cmd(new NameOfShowCaseItemTC(showcase, position, outtext));
+ boost::shared_ptr<BasicServerCommand>cmd(new NameOfShowCaseItemTC(showcase, position, outtext, titem.getWorth()));
cp->Connection->addCommand(cmd);
}
}
@@ -569,6 +533,7 @@ void World::lookAtShowcaseItem(Player *cp, unsigned char showcase, unsigned char
void World::lookAtInventoryItem(Player *cp, unsigned char position) {
if (cp->characterItems[ position ].getId() != 0) {
std::string outtext;
+ TYPE_OF_WORTH worth = 0;
if (ItemNames->find(cp->characterItems[ position ].getId(), tempNames)) {
Item titem = cp->characterItems[ position ];
@@ -591,6 +556,8 @@ void World::lookAtInventoryItem(Player *cp, unsigned char position) {
script->LookAtItem(cp, n_item);
return;
}
+
+ worth = titem.getWorth();
}
switch (cp->getPlayerLanguage()) {
@@ -625,7 +592,7 @@ void World::lookAtInventoryItem(Player *cp, unsigned char position) {
}
}
- boost::shared_ptr<BasicServerCommand>cmd(new NameOfInventoryItemTC(position, outtext));
+ boost::shared_ptr<BasicServerCommand>cmd(new NameOfInventoryItemTC(position, outtext, worth));
cp->Connection->addCommand(cmd);
}
}
@@ -53,7 +53,6 @@ CommandFactory::CommandFactory() {
templateList[ C_LOOKATINVENTORYITEM_TS ] = new LookAtInventoryItemTS();
templateList[ C_ATTACKSTOP_TS ] = new AttackStopTS();
templateList[ C_REQUESTSKILLS_TS ] = new RequestSkillsTS();
- templateList[ C_LOOKATMENUITEM_TS ] = new LookAtMenuItemTS();
templateList[ C_KEEPALIVE_TS ] = new KeepAliveTS();
templateList[ BB_KEEPALIVE_TS ] = new BBKeepAliveTS();
templateList[ BB_BROADCAST_TS ] = new BBBroadCastTS();
@@ -83,7 +83,6 @@ enum clientcommands {
C_LOOKATINVENTORYITEM_TS = 0xDF,
C_ATTACKSTOP_TS = 0xDE,
C_REQUESTSKILLS_TS = 0xDD,
- C_LOOKATMENUITEM_TS = 0xDC,
C_KEEPALIVE_TS = 0xD8,
C_REQUESTAPPEARANCE_TS = 0x0E,
C_INPUTDIALOG_TS = 0x50,
@@ -1254,45 +1253,6 @@ class UseTS : public BasicClientCommand {
/**
*@ingroup Clientcommands
-*character looks at an menu item
-*/
-class LookAtMenuItemTS : public BasicClientCommand {
-public:
- LookAtMenuItemTS() : BasicClientCommand(C_LOOKATMENUITEM_TS) {
- }
-
- virtual ~LookAtMenuItemTS() {};
-
- virtual void decodeData() {
- pos = getUnsignedCharFromBuffer();
- id = getShortIntFromBuffer();
- }
-
- void performAction(Player *player) {
- Logger::writeMessage("World_Debug",player->name + "looks at an item from a menu.");
- time(&(player->lastaction));
-#ifdef DO_UNCONSCIOUS
-
- if (player->IsAlive() && player->IsConscious())
-#else
- if (player->IsAlive())
-#endif
- {
- World::get()->lookAtMenueItem(player, pos, id);
- player->actionPoints -= P_LOOK_COST;
- }
- }
-
- boost::shared_ptr<BasicClientCommand> clone() {
- boost::shared_ptr<BasicClientCommand>cmd(new LookAtMenuItemTS());
- return cmd;
- }
- TYPE_OF_ITEM_ID id;
- unsigned char pos;
-};
-
-/**
-*@ingroup Clientcommands
*client gives signal that he is ok
*/
class KeepAliveTS : public BasicClientCommand {
@@ -154,15 +154,17 @@ TargetLostTC::TargetLostTC() : BasicServerCommand(SC_TARGETLOST_TC) {
AttackAcknowledgedTC::AttackAcknowledgedTC() : BasicServerCommand(SC_ATTACKACKNOWLEDGED_TC) {
}
-NameOfInventoryItemTC::NameOfInventoryItemTC(unsigned char pos, std::string name) : BasicServerCommand(SC_NAMEOFINVENTORYITEM_TC) {
+NameOfInventoryItemTC::NameOfInventoryItemTC(unsigned char pos, std::string name, TYPE_OF_WORTH worth) : BasicServerCommand(SC_NAMEOFINVENTORYITEM_TC) {
addUnsignedCharToBuffer(pos);
addStringToBuffer(name);
+ addIntToBuffer(worth);
}
-NameOfShowCaseItemTC::NameOfShowCaseItemTC(unsigned char showcase, unsigned char pos, std::string name) : BasicServerCommand(SC_NAMEOFSHOWCASEITEM_TC) {
+NameOfShowCaseItemTC::NameOfShowCaseItemTC(unsigned char showcase, unsigned char pos, std::string name, TYPE_OF_WORTH worth) : BasicServerCommand(SC_NAMEOFSHOWCASEITEM_TC) {
addUnsignedCharToBuffer(showcase);
addUnsignedCharToBuffer(pos);
addStringToBuffer(name);
+ addIntToBuffer(worth);
}
NameOfMapItemTC::NameOfMapItemTC(short int x, short int y, short int z, std::string name) : BasicServerCommand(SC_NAMEOFMAPITEM_TC) {
@@ -140,12 +140,12 @@ class AttackAcknowledgedTC : public BasicServerCommand {
class NameOfInventoryItemTC : public BasicServerCommand {
public:
- NameOfInventoryItemTC(unsigned char pos, std::string name);
+ NameOfInventoryItemTC(unsigned char pos, std::string name, TYPE_OF_WORTH worth);
};
class NameOfShowCaseItemTC : public BasicServerCommand {
public:
- NameOfShowCaseItemTC(unsigned char showcase, unsigned char pos, std::string name);
+ NameOfShowCaseItemTC(unsigned char showcase, unsigned char pos, std::string name, TYPE_OF_WORTH worth);
};
class NameOfMapItemTC : public BasicServerCommand {

0 comments on commit 36f1009

Please sign in to comment.