| 262 | */ |
| 263 | |
| 264 | CTaskGroup *CTaskManager::AddTaskGroup( const char *name, CIcarus* icarus ) |
| 265 | { |
| 266 | CTaskGroup *group; |
| 267 | |
| 268 | //Collect any garbage |
| 269 | taskGroupName_m::iterator tgni; |
| 270 | tgni = m_taskGroupNameMap.find( name ); |
| 271 | |
| 272 | if ( tgni != m_taskGroupNameMap.end() ) |
| 273 | { |
| 274 | group = (*tgni).second; |
| 275 | |
| 276 | //Clear it and just move on |
| 277 | group->Init(); |
| 278 | |
| 279 | return group; |
| 280 | } |
| 281 | |
| 282 | //Allocate a new one |
| 283 | group = new CTaskGroup; |
| 284 | |
| 285 | //TODO: Emit warning |
| 286 | assert( group ); |
| 287 | if ( group == NULL ) |
| 288 | { |
| 289 | icarus->GetGame()->DebugPrint(IGameInterface::WL_ERROR, "Unable to allocate task group \"%s\"\n", name ); |
| 290 | return NULL; |
| 291 | } |
| 292 | |
| 293 | //Setup the internal information |
| 294 | group->SetGUID( m_GUID++ ); |
| 295 | |
| 296 | //Add it to the list and associate it for retrieval later |
| 297 | m_taskGroups.insert( m_taskGroups.end(), group ); |
| 298 | m_taskGroupNameMap[ name ] = group; |
| 299 | m_taskGroupIDMap[ group->GetGUID() ] = group; |
| 300 | |
| 301 | return group; |
| 302 | } |
| 303 | |
| 304 | /* |
| 305 | ------------------------- |