Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List

Slot.cpp

00001 /*
00002 Copyright 2003 - 2005 Elliott Kleinrock, Dan Neely, Kurt W. Over, Damon Domjan
00003 
00004 This file is part of FreeStars, a free clone of the Stars! game.
00005 
00006 FreeStars is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 FreeStars is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with FreeStars; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 The full GPL Copyright notice should be in the file COPYING.txt
00021 
00022 Contact:
00023 Email Elliott at 9jm0tjj02@sneakemail.com
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 }

Generated on Mon Aug 8 21:33:45 2005 for Freestars by  doxygen 1.4.2-20050421