00001 /* 00002 * The Mana World 00003 * Copyright (C) 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #include "floor_item.h" 00023 #include "flooritemmanager.h" 00024 00025 #include "utils/dtor.h" 00026 00027 FloorItemManager::~FloorItemManager() 00028 { 00029 clear(); 00030 } 00031 00032 FloorItem *FloorItemManager::create(int id, int itemId, 00033 int x, int y, Map *map) 00034 { 00035 FloorItem *floorItem = new FloorItem(id, itemId, x, y, map); 00036 mFloorItems.push_back(floorItem); 00037 return floorItem; 00038 } 00039 00040 void FloorItemManager::destroy(FloorItem *item) 00041 { 00042 mFloorItems.remove(item); 00043 delete item; 00044 } 00045 00046 void FloorItemManager::clear() 00047 { 00048 delete_all(mFloorItems); 00049 mFloorItems.clear(); 00050 } 00051 00052 FloorItem *FloorItemManager::findById(int id) 00053 { 00054 FloorItemIterator i; 00055 for (i = mFloorItems.begin(); i != mFloorItems.end(); i++) 00056 { 00057 if ((*i)->getId() == id) 00058 { 00059 return *i; 00060 } 00061 } 00062 00063 return NULL; 00064 } 00065 00066 FloorItem *FloorItemManager::findByCoordinates(int x, int y) 00067 { 00068 FloorItemIterator i; 00069 for (i = mFloorItems.begin(); i != mFloorItems.end(); i++) 00070 { 00071 if ((*i)->getX() == x && (*i)->getY() == y) 00072 { 00073 return *i; 00074 } 00075 } 00076 00077 return NULL; 00078 }