| 520 |
|
objType ); |
| 521 |
|
painCave.isFatal = 1; |
| 522 |
|
simError(); |
| 523 |
+ |
} |
| 524 |
+ |
} |
| 525 |
+ |
|
| 526 |
+ |
void StuntDouble::addProperty(GenericData* data){ |
| 527 |
+ |
map<string, GenericData*>::iterator result; |
| 528 |
+ |
result = properties.find(data->getID()); |
| 529 |
+ |
|
| 530 |
+ |
//we can't simply use properties[prop->getID()] = prop, |
| 531 |
+ |
//it will cause memory leak if we already contain a propery which has the same name of prop |
| 532 |
+ |
|
| 533 |
+ |
if(result != properties.end()){ |
| 534 |
+ |
delete (*result).second; |
| 535 |
+ |
(*result).second = data; |
| 536 |
|
} |
| 537 |
+ |
else |
| 538 |
+ |
properties[data->getID()] = data; |
| 539 |
+ |
|
| 540 |
+ |
|
| 541 |
|
} |
| 542 |
+ |
void StuntDouble::removeProperty(const string& propName){ |
| 543 |
+ |
map<string, GenericData*>::iterator result; |
| 544 |
+ |
|
| 545 |
+ |
result = properties.find(propName); |
| 546 |
+ |
|
| 547 |
+ |
if(result != properties.end()) |
| 548 |
+ |
properties.erase(result); |
| 549 |
+ |
|
| 550 |
+ |
} |
| 551 |
+ |
GenericData* StuntDouble::getProperty(const string& propName){ |
| 552 |
+ |
map<string, GenericData*>::iterator result; |
| 553 |
+ |
|
| 554 |
+ |
|
| 555 |
+ |
result = properties.find(propName); |
| 556 |
+ |
|
| 557 |
+ |
if(result != properties.end()) |
| 558 |
+ |
return (*result).second; |
| 559 |
+ |
else |
| 560 |
+ |
return NULL; |
| 561 |
+ |
} |