|
39 | 39 | #include "Common/INI.h" |
40 | 40 | #include "Common/GlobalData.h" |
41 | 41 | #include "GameClient/Image.h" |
42 | | - |
| 42 | +#include "Common/NameKeyGenerator.h" |
43 | 43 |
|
44 | 44 | // PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// |
45 | 45 | const FieldParse Image::m_imageFieldParseTable[] = |
@@ -154,7 +154,6 @@ Image::Image( void ) |
154 | 154 | m_imageSize.y = 0; |
155 | 155 | m_rawTextureData = NULL; |
156 | 156 | m_status = IMAGE_STATUS_NONE; |
157 | | - m_next = NULL; |
158 | 157 |
|
159 | 158 | } |
160 | 159 |
|
@@ -199,113 +198,31 @@ UnsignedInt Image::clearStatus( UnsignedInt bit ) |
199 | 198 | //------------------------------------------------------------------------------------------------- |
200 | 199 | ImageCollection::ImageCollection( void ) |
201 | 200 | { |
202 | | - |
203 | | - m_imageList = NULL; |
204 | | - |
205 | 201 | } |
206 | 202 |
|
207 | 203 | //------------------------------------------------------------------------------------------------- |
208 | 204 | //------------------------------------------------------------------------------------------------- |
209 | 205 | ImageCollection::~ImageCollection( void ) |
210 | 206 | { |
211 | | - Image *image, *next; |
212 | | - |
213 | | - // delete the images |
214 | | - image = m_imageList; |
215 | | - while( image ) |
216 | | - { |
217 | | - |
218 | | - next = image->m_next; |
219 | | - deleteInstance(image); |
220 | | - image = next; |
221 | | - |
222 | | - } |
223 | | - m_imageList = NULL; |
224 | | - |
| 207 | + for (std::map<unsigned,Image *>::iterator i=m_imageMap.begin();i!=m_imageMap.end();++i) |
| 208 | + deleteInstance(i->second); |
225 | 209 | } |
226 | 210 |
|
227 | 211 | //------------------------------------------------------------------------------------------------- |
228 | 212 | /** Return the next image in the collection */ |
229 | 213 | //------------------------------------------------------------------------------------------------- |
230 | | -Image *ImageCollection::nextImage( Image *image ) |
| 214 | +void ImageCollection::addImage( Image *image ) |
231 | 215 | { |
232 | | - |
233 | | - if( image ) |
234 | | - return image->m_next; |
235 | | - |
236 | | - return NULL; |
237 | | - |
238 | | -} |
239 | | - |
240 | | -//------------------------------------------------------------------------------------------------- |
241 | | -/** Allocate a new image, tie to the image list and return it */ |
242 | | -//------------------------------------------------------------------------------------------------- |
243 | | -Image *ImageCollection::newImage( void ) |
244 | | -{ |
245 | | - Image *image = newInstance(Image); |
246 | | - |
247 | | - // attach to collection list |
248 | | - image->m_next = m_imageList; |
249 | | - m_imageList = image; |
250 | | - |
251 | | - return image; |
252 | | - |
| 216 | + m_imageMap[TheNameKeyGenerator->nameToLowercaseKey(image->getName())]=image; |
253 | 217 | } |
254 | 218 |
|
255 | 219 | //------------------------------------------------------------------------------------------------- |
256 | 220 | /** Find an image given the image name */ |
257 | 221 | //------------------------------------------------------------------------------------------------- |
258 | 222 | const Image *ImageCollection::findImageByName( const AsciiString& name ) |
259 | 223 | { |
260 | | - Image *image; |
261 | | - |
262 | | - /** @todo this needs to be more intelligent if this image collection |
263 | | - becomes a real system we use a lot */ |
264 | | - |
265 | | - // search the images |
266 | | - image = m_imageList; |
267 | | - while( image ) |
268 | | - { |
269 | | - |
270 | | - // |
271 | | - // want to do a case insensitive compare here cause image INI files are |
272 | | - // autogenerated from filenames using the image packer tool |
273 | | - // |
274 | | - if( image->getName().compareNoCase( name.str() ) == 0 ) |
275 | | - return image; |
276 | | - image = image->m_next; |
277 | | - |
278 | | - } |
279 | | - |
280 | | - // not found |
281 | | - return NULL; |
282 | | - |
283 | | -} |
284 | | - |
285 | | -//------------------------------------------------------------------------------------------------- |
286 | | -/** Find image given image filename */ |
287 | | -//------------------------------------------------------------------------------------------------- |
288 | | -const Image *ImageCollection::findImageByFilename( const AsciiString& filename ) |
289 | | -{ |
290 | | - Image *image; |
291 | | - |
292 | | - /** @todo this needs to be more intelligent if this image collection |
293 | | - becomes a real system we use a lot */ |
294 | | - |
295 | | - // search the images |
296 | | - image = m_imageList; |
297 | | - while( image ) |
298 | | - { |
299 | | - |
300 | | - if( image->getFilename() == filename ) |
301 | | - return image; |
302 | | - image = image->m_next; |
303 | | - |
304 | | - } |
305 | | - |
306 | | - // not found |
307 | | - return NULL; |
308 | | - |
| 224 | + std::map<unsigned,Image *>::iterator i=m_imageMap.find(TheNameKeyGenerator->nameToLowercaseKey(name)); |
| 225 | + return i==m_imageMap.end()?NULL:i->second; |
309 | 226 | } |
310 | 227 |
|
311 | 228 | //------------------------------------------------------------------------------------------------- |
|
0 commit comments