| 338 | //--------------------------------------------------------------------------- |
| 339 | |
| 340 | SimObject* findObject(const char* name) |
| 341 | { |
| 342 | // Play nice with bad code - JDD |
| 343 | if( !name ) |
| 344 | return NULL; |
| 345 | |
| 346 | SimObject *obj; |
| 347 | char c = *name; |
| 348 | if(c == '/') |
| 349 | return gRootGroup->findObject(name + 1 ); |
| 350 | if(c >= '0' && c <= '9') |
| 351 | { |
| 352 | // it's an id group |
| 353 | const char* temp = name + 1; |
| 354 | for(;;) |
| 355 | { |
| 356 | c = *temp++; |
| 357 | if(!c) |
| 358 | return findObject(dAtoi(name)); |
| 359 | else if(c == '/') |
| 360 | { |
| 361 | obj = findObject(dAtoi(name)); |
| 362 | if(!obj) |
| 363 | return NULL; |
| 364 | return obj->findObject(temp); |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | S32 len; |
| 369 | |
| 370 | //-Mat ensure > 0, instead of just != 0 (prevent running through bogus memory on non-NULL-terminated strings) |
| 371 | for(len = 0; name[len] > 0 && name[len] != '/'; len++) |
| 372 | ; |
| 373 | StringTableEntry stName = StringTable->lookupn(name, len); |
| 374 | if(!stName) |
| 375 | return NULL; |
| 376 | obj = gNameDictionary->find(stName); |
| 377 | if(!name[len]) |
| 378 | return obj; |
| 379 | if(!obj) |
| 380 | return NULL; |
| 381 | return obj->findObject(name + len + 1); |
| 382 | } |
| 383 | |
| 384 | SimObject* findObject(SimObjectId id) |
| 385 | { |
nothing calls this directly
no test coverage detected