Skip to content

Commit

Permalink
add item worth to lookat, remove lookat for old menus
Browse files Browse the repository at this point in the history
  • Loading branch information
vilarion committed Apr 30, 2012
1 parent 360c016 commit 36f1009
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 91 deletions.
10 changes: 10 additions & 0 deletions Item.cpp
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Item.hpp
Expand Up @@ -114,6 +114,7 @@ class Item {

bool survivesAging();
bool isContainer() const;
TYPE_OF_WORTH getWorth() const;
bool isComplete() const;
bool isPermanent() const;
void makePermanent();
Expand Down
6 changes: 0 additions & 6 deletions World.hpp
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions WorldIMPLScriptHelp.cpp
Expand Up @@ -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) {
Expand Down
43 changes: 5 additions & 38 deletions WorldIMPLTalk.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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 ];
Expand All @@ -591,6 +556,8 @@ void World::lookAtInventoryItem(Player *cp, unsigned char position) {
script->LookAtItem(cp, n_item);
return;
}

worth = titem.getWorth();
}

switch (cp->getPlayerLanguage()) {
Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion netinterface/CommandFactory.cpp
Expand Up @@ -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();
Expand Down
40 changes: 0 additions & 40 deletions netinterface/protocol/ClientCommands.hpp
Expand Up @@ -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,
Expand Down Expand Up @@ -1252,45 +1251,6 @@ class UseTS : public BasicClientCommand {
ByteStack bs;
};

/**
*@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
Expand Down
6 changes: 4 additions & 2 deletions netinterface/protocol/ServerCommands.cpp
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions netinterface/protocol/ServerCommands.hpp
Expand Up @@ -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 {
Expand Down

0 comments on commit 36f1009

Please sign in to comment.