00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "FSServer.h"
00027
00028 #ifdef _DEBUG
00029 #define new DEBUG_NEW
00030 #endif
00031
00032 Slot::Slot(const TiXmlNode * node, long Pos)
00033 {
00034 const TiXmlNode * child1;
00035 const char * ptr;
00036
00037 mPosition = Pos;
00038 Allowed = CT_NONE;
00039 count = 0;
00040 component = NULL;
00041 mSlotTop = 0;
00042 mSlotLeft = 0;
00043 for (child1 = node->FirstChild(); child1; child1 = child1->NextSibling()) {
00044 if (child1->Type() != TiXmlNode::ELEMENT)
00045 continue;
00046
00047 if (stricmp(child1->Value(), "Type") == 0) {
00048 ptr = GetString(child1);
00049 if (ptr == NULL)
00050 break;
00051
00052 if (stricmp(ptr, "Armor") == 0)
00053 Allowed |= CT_ARMOR;
00054 else if (stricmp(ptr, "Shield") == 0)
00055 Allowed |= CT_SHIELD;
00056 else if (stricmp(ptr, "Weapon") == 0)
00057 Allowed |= CT_WEAPON;
00058 else if (stricmp(ptr, "Bomb") == 0)
00059 Allowed |= CT_BOMB;
00060 else if (stricmp(ptr, "Electrical") == 0)
00061 Allowed |= CT_ELEC;
00062 else if (stricmp(ptr, "Engine") == 0)
00063 Allowed |= CT_ENGINE;
00064 else if (stricmp(ptr, "Orbital") == 0)
00065 Allowed |= CT_ORBITAL;
00066 else if (stricmp(ptr, "Mine Layer") == 0)
00067 Allowed |= CT_MINELAY;
00068 else if (stricmp(ptr, "Remote Miner") == 0)
00069 Allowed |= CT_MINER;
00070 else if (stricmp(ptr, "Mechanical") == 0)
00071 Allowed |= CT_MECH;
00072 else if (stricmp(ptr, "Scanner") == 0)
00073 Allowed |= CT_SCANNER;
00074 else if (stricmp(ptr, "General") == 0)
00075 Allowed |= CT_GENERAL;
00076 else {
00077 Message * mess = TheGame->AddMessage("Warning: Unknown slot type");
00078 mess->AddItem("", ptr);
00079 }
00080 } else if (stricmp(child1->Value(), "Number") == 0) {
00081 ptr = GetString(child1);
00082 if (ptr == NULL)
00083 break;
00084
00085 count = atol(ptr);
00086 } else if (stricmp(child1->Value(), "SlotLeft") == 0) {
00087 mSlotLeft = GetLong(child1);
00088 } else if (stricmp(child1->Value(), "SlotTop") == 0) {
00089 mSlotTop = GetLong(child1);
00090 } else {
00091 Message * mess = TheGame->AddMessage("Warning: Unknown section");
00092 mess->AddItem("Slot", child1->Value());
00093 }
00094 }
00095 }
00096
00097 bool operator==(const Slot & s1, const Slot & s2)
00098 {
00099 if (s1.Allowed != s2.Allowed)
00100 return false;
00101
00102 if (s1.component != s2.component)
00103 return false;
00104
00105 if (s1.count != s2.count)
00106 return false;
00107
00108 return true;
00109 }