From: Andrew C. <ac...@us...> - 2004-03-15 05:44:48
|
Update of /cvsroot/planeshift/planeshift/src/common/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17031/src/common/util Added Files: slots.cpp slots.h Log Message: Forgot to add these --- NEW FILE: slots.cpp --- /* * * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include "psconfig.h" #include "slots.h" SlotName::SlotName() { // Construct the hash map with our name->enum ID. slotNames.Register ("righthand", PSCHARACTER_SLOT_RIGHTHAND ); slotNames.Register ("lefthand", PSCHARACTER_SLOT_LEFTHAND ); slotNames.Register ("bothhands", PSCHARACTER_SLOT_BOTHHANDS ); slotNames.Register ("head", PSCHARACTER_SLOT_HEAD ); slotNames.Register ("neck", PSCHARACTER_SLOT_NECK ); slotNames.Register ("back", PSCHARACTER_SLOT_BACK ); slotNames.Register ("arms", PSCHARACTER_SLOT_ARMS ); slotNames.Register ("gloves", PSCHARACTER_SLOT_GLOVES ); slotNames.Register ("boots", PSCHARACTER_SLOT_BOOTS ); slotNames.Register ("legs", PSCHARACTER_SLOT_LEGS ); slotNames.Register ("bracers", PSCHARACTER_SLOT_BRACERS ); slotNames.Register ("torso", PSCHARACTER_SLOT_TORSO ); slotNames.Register ("mind", PSCHARACTER_SLOT_MIND ); } int SlotName::GetID( const csString& name ) { return slotNames.Request( name ); } const char* SlotName::GetName( int id ) { return slotNames.Request( id ); } --- NEW FILE: slots.h --- /* * * * Copyright (C) 2001 PlaneShift Team (in...@pl..., * http://www.planeshift.it) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef PS_HEADER_SLOTS #define PS_HEADER_SLOTS #include <csutil/csstring.h> #include <csutil/strhash.h> /** Holds a list of the possible socket identifiers that items can be attached to. */ enum EQUIPMENT_SLOTS { PSCHARACTER_SLOT_NONE = -1, PSCHARACTER_SLOT_RIGHTHAND = 0, PSCHARACTER_SLOT_LEFTHAND = 1, PSCHARACTER_SLOT_BOTHHANDS = 2, PSCHARACTER_SLOT_HEAD = 3, PSCHARACTER_SLOT_NECK = 4, PSCHARACTER_SLOT_BACK = 5, PSCHARACTER_SLOT_ARMS = 6, PSCHARACTER_SLOT_GLOVES = 7, PSCHARACTER_SLOT_BOOTS = 8, PSCHARACTER_SLOT_LEGS = 9, PSCHARACTER_SLOT_BELT = 10, PSCHARACTER_SLOT_BRACERS = 11, PSCHARACTER_SLOT_TORSO = 12, PSCHARACTER_SLOT_MIND = 13, PSCHARACTER_SLOT_COUNT = 14 }; /** A hash map class that stores a name->ID of sockets. This way we can easily * work with numbers and then convert to string if we need to. This is shared * class across both the client and server since both may need this. */ class SlotName { public: SlotName(); /// Get the enum ID from a string name. int GetID( const csString& name ); /// Get the name from an enum const char* GetName( int id ); private: csStringHash slotNames; }; #endif |