WINTERMUTE: Wrap _name in base_named_object in getters/setters.

This commit is contained in:
Einar Johan Trøan Sømåen 2012-07-22 23:17:32 +02:00
parent f6a5a2a0d5
commit 8c378f794e
31 changed files with 109 additions and 91 deletions

View File

@ -940,7 +940,7 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
bool Found = false;
for (int i = 0; i < _anims.getSize(); i++) {
if (scumm_stricmp(_anims[i]->_name, AnimName) == 0) {
if (scumm_stricmp(_anims[i]->getName(), AnimName) == 0) {
// invalidate sprites in use
if (_anims[i]->containsSprite(_tempSprite2)) _tempSprite2 = NULL;
if (_anims[i]->containsSprite(_currentSprite)) _currentSprite = NULL;
@ -1109,7 +1109,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) {
if (_animSprite) {
bool res = _animSprite->loadFile(_forcedTalkAnimName);
if (DID_FAIL(res)) {
_gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName);
_gameRef->LOG(res, "AdActor::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName);
delete _animSprite;
_animSprite = NULL;
} else return _animSprite;
@ -1131,7 +1131,7 @@ BaseSprite *AdActor::getTalkStance(const char *stance) {
if (!ret) {
BaseArray<AdSpriteSet *, AdSpriteSet *> TalkAnims;
for (int i = 0; i < _anims.getSize(); i++) {
if (_talkAnimName.compareToIgnoreCase(_anims[i]->_name) == 0)
if (_talkAnimName.compareToIgnoreCase(_anims[i]->getName()) == 0)
TalkAnims.add(_anims[i]);
}
@ -1156,7 +1156,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) {
if (stance != NULL) {
// search special stances
for (int i = 0; i < _talkSpritesEx.getSize(); i++) {
if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) {
if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) {
ret = _talkSpritesEx[i]->getSprite(_dir);
break;
}
@ -1164,7 +1164,7 @@ BaseSprite *AdActor::getTalkStanceOld(const char *stance) {
if (ret == NULL) {
// search generic stances
for (int i = 0; i < _talkSprites.getSize(); i++) {
if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) {
if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) {
ret = _talkSprites[i]->getSprite(_dir);
break;
}
@ -1254,7 +1254,7 @@ int AdActor::getHeight() {
//////////////////////////////////////////////////////////////////////////
AdSpriteSet *AdActor::getAnimByName(const Common::String &animName) {
for (int i = 0; i < _anims.getSize(); i++) {
if (animName.compareToIgnoreCase(_anims[i]->_name) == 0)
if (animName.compareToIgnoreCase(_anims[i]->getName()) == 0)
return _anims[i];
}
return NULL;

View File

@ -462,7 +462,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) {
}
if (_region && _sprite) {
_gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", _name);
_gameRef->LOG(0, "Warning: Entity '%s' has both sprite and region.", getName());
}
updatePosition();
@ -878,7 +878,7 @@ const char *AdEntity::scToString() {
//////////////////////////////////////////////////////////////////////////
bool AdEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "ENTITY {\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
if (_subtype == ENTITY_SOUND)
buffer->putTextIndent(indent + 2, "SUBTYPE=\"SOUND\"\n");
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());

View File

@ -250,7 +250,7 @@ bool AdGame::changeScene(const char *filename, bool fadeIn) {
} else {
_scene->applyEvent("SceneShutdown", true);
setPrevSceneName(_scene->_name);
setPrevSceneName(_scene->getName());
setPrevSceneFilename(_scene->getFilename());
if (!_tempDisableSaveState) _scene->saveState();
@ -657,7 +657,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (val->getNative() == Inv->_takenItems[j]) {
stack->pushBool(true);
return STATUS_OK;
} else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->_name) == 0) {
} else if (scumm_stricmp(val->getString(), Inv->_takenItems[j]->getName()) == 0) {
stack->pushBool(true);
return STATUS_OK;
}
@ -1093,7 +1093,7 @@ bool AdGame::showCursor() {
_lastCursor = origLastCursor;
}
if (_activeObject && _selectedItem->_cursorHover && _activeObject->getExtendedFlag("usable")) {
if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->_name))
if (!_smartItemCursor || _activeObject->canHandleEvent(_selectedItem->getName()))
return drawCursor(_selectedItem->_cursorHover);
else
return drawCursor(_selectedItem->_cursorNormal);
@ -1414,7 +1414,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) {
if (item && !DID_FAIL(item->loadBuffer(params, false))) {
// delete item with the same name, if exists
if (merge) {
AdItem *PrevItem = getItemByName(item->_name);
AdItem *PrevItem = getItemByName(item->getName());
if (PrevItem) deleteItem(PrevItem);
}
addItem(item);
@ -1767,7 +1767,7 @@ bool AdGame::isItemTaken(char *itemName) {
AdInventory *Inv = _inventories[i];
for (int j = 0; j < Inv->_takenItems.getSize(); j++) {
if (scumm_stricmp(itemName, Inv->_takenItems[j]->_name) == 0) {
if (scumm_stricmp(itemName, Inv->_takenItems[j]->getName()) == 0) {
return true;
}
}
@ -1778,7 +1778,7 @@ bool AdGame::isItemTaken(char *itemName) {
//////////////////////////////////////////////////////////////////////////
AdItem *AdGame::getItemByName(const char *name) {
for (int i = 0; i < _items.getSize(); i++) {
if (scumm_stricmp(_items[i]->_name, name) == 0) return _items[i];
if (scumm_stricmp(_items[i]->getName(), name) == 0) return _items[i];
}
return NULL;
}
@ -1831,7 +1831,7 @@ bool AdGame::deleteItem(AdItem *item) {
if (!item) return STATUS_FAILED;
if (_selectedItem == item) _selectedItem = NULL;
_scene->handleItemAssociations(item->_name, false);
_scene->handleItemAssociations(item->getName(), false);
// remove from all inventories
for (int i = 0; i < _inventories.getSize(); i++) {
@ -2036,7 +2036,7 @@ bool AdGame::displayDebugInfo() {
sprintf(str, "Mouse: %d, %d (scene: %d, %d)", _mousePos.x, _mousePos.y, _mousePos.x + _scene->getOffsetLeft(), _mousePos.y + _scene->getOffsetTop());
_systemFont->drawText((byte *)str, 0, 90, _renderer->_width, TAL_RIGHT);
sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->_name) ? _scene->_name : "???", _prevSceneName ? _prevSceneName : "???");
sprintf(str, "Scene: %s (prev: %s)", (_scene && _scene->getName()) ? _scene->getName() : "???", _prevSceneName ? _prevSceneName : "???");
_systemFont->drawText((byte *)str, 0, 110, _renderer->_width, TAL_RIGHT);
}
return BaseGame::displayDebugInfo();

View File

@ -57,12 +57,12 @@ bool AdInventory::insertItem(const char *name, const char *insertAfter) {
int insertIndex = -1;
for (int i = 0; i < _takenItems.getSize(); i++) {
if (scumm_stricmp(_takenItems[i]->_name, name) == 0) {
if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) {
_takenItems.removeAt(i);
i--;
continue;
}
if (insertAfter && scumm_stricmp(_takenItems[i]->_name, insertAfter) == 0) insertIndex = i + 1;
if (insertAfter && scumm_stricmp(_takenItems[i]->getName(), insertAfter) == 0) insertIndex = i + 1;
}
@ -78,7 +78,7 @@ bool AdInventory::removeItem(const char *name) {
if (name == NULL) return STATUS_FAILED;
for (int i = 0; i < _takenItems.getSize(); i++) {
if (scumm_stricmp(_takenItems[i]->_name, name) == 0) {
if (scumm_stricmp(_takenItems[i]->getName(), name) == 0) {
if (((AdGame *)_gameRef)->_selectedItem == _takenItems[i])((AdGame *)_gameRef)->_selectedItem = NULL;
_takenItems.removeAt(i);
return STATUS_OK;

View File

@ -79,12 +79,12 @@ bool AdInventoryBox::listen(BaseScriptHolder *param1, uint32 param2) {
switch (obj->_type) {
case UI_BUTTON:
if (scumm_stricmp(obj->_name, "close") == 0) {
if (scumm_stricmp(obj->getName(), "close") == 0) {
_visible = false;
} else if (scumm_stricmp(obj->_name, "prev") == 0) {
} else if (scumm_stricmp(obj->getName(), "prev") == 0) {
_scrollOffset -= _scrollBy;
_scrollOffset = MAX(_scrollOffset, 0);
} else if (scumm_stricmp(obj->_name, "next") == 0) {
} else if (scumm_stricmp(obj->getName(), "next") == 0) {
_scrollOffset += _scrollBy;
} else return BaseObject::listen(param1, param2);
break;
@ -321,7 +321,7 @@ bool AdInventoryBox::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "INVENTORY_BOX\n");
buffer->putTextIndent(indent, "{\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "AREA { %d, %d, %d, %d }\n", _itemsArea.left, _itemsArea.top, _itemsArea.right, _itemsArea.bottom);

View File

@ -582,7 +582,7 @@ ScValue *AdItem::scGetProperty(const char *name) {
// Name
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Name") == 0) {
_scValue->setString(_name);
_scValue->setString(getName());
return _scValue;
}

View File

@ -237,8 +237,8 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (val->_type == VAL_INT) node = val->getInt();
else { // get by name
for (int i = 0; i < _nodes.getSize(); i++) {
if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->_name, val->getString()) == 0) ||
(_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->_name, val->getString()) == 0)) {
if ((_nodes[i]->_type == OBJECT_ENTITY && scumm_stricmp(_nodes[i]->_entity->getName(), val->getString()) == 0) ||
(_nodes[i]->_type == OBJECT_REGION && scumm_stricmp(_nodes[i]->_region->getName(), val->getString()) == 0)) {
node = i;
break;
}
@ -478,7 +478,7 @@ const char *AdLayer::scToString() {
//////////////////////////////////////////////////////////////////////////
bool AdLayer::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "LAYER {\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "MAIN=%s\n", _main ? "TRUE" : "FALSE");
buffer->putTextIndent(indent + 2, "WIDTH=%d\n", _width);

View File

@ -156,12 +156,12 @@ bool AdObject::playAnim(const char *filename) {
_animSprite = NULL;
_animSprite = new BaseSprite(_gameRef, this);
if (!_animSprite) {
_gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename);
_gameRef->LOG(0, "AdObject::PlayAnim: error creating temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename);
return STATUS_FAILED;
}
bool res = _animSprite->loadFile(filename);
if (DID_FAIL(res)) {
_gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", _name, filename);
_gameRef->LOG(res, "AdObject::PlayAnim: error loading temp sprite (object:\"%s\" sprite:\"%s\")", getName(), filename);
delete _animSprite;
_animSprite = NULL;
return res;
@ -296,7 +296,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
} else if (val->isString()) {
const char *regionName = val->getString();
for (i = 0; i < main->_nodes.getSize(); i++) {
if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->_name && scumm_stricmp(main->_nodes[i]->_region->_name, regionName) == 0) {
if (main->_nodes[i]->_type == OBJECT_REGION && main->_nodes[i]->_region->getName() && scumm_stricmp(main->_nodes[i]->_region->getName(), regionName) == 0) {
_stickRegion = main->_nodes[i]->_region;
regFound = true;
break;
@ -437,7 +437,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
if (val->getNative() == _inventory->_takenItems[i]) {
stack->pushBool(true);
return STATUS_OK;
} else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->_name) == 0) {
} else if (scumm_stricmp(val->getString(), _inventory->_takenItems[i]->getName()) == 0) {
stack->pushBool(true);
return STATUS_OK;
}
@ -539,7 +539,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
} else {
const char *attachmentName = val->getString();
for (int i = 0; i < _attachmentsPre.getSize(); i++) {
if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) {
if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) {
found = true;
_gameRef->unregisterObject(_attachmentsPre[i]);
_attachmentsPre.removeAt(i);
@ -547,7 +547,7 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
}
}
for (int i = 0; i < _attachmentsPost.getSize(); i++) {
if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) {
if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) {
found = true;
_gameRef->unregisterObject(_attachmentsPost[i]);
_attachmentsPost.removeAt(i);
@ -582,14 +582,14 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
} else {
const char *attachmentName = val->getString();
for (int i = 0; i < _attachmentsPre.getSize(); i++) {
if (_attachmentsPre[i]->_name && scumm_stricmp(_attachmentsPre[i]->_name, attachmentName) == 0) {
if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) {
ret = _attachmentsPre[i];
break;
}
}
if (!ret) {
for (int i = 0; i < _attachmentsPost.getSize(); i++) {
if (_attachmentsPost[i]->_name && scumm_stricmp(_attachmentsPost[i]->_name, attachmentName) == 0) {
if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) {
ret = _attachmentsPre[i];
break;
}

View File

@ -252,7 +252,7 @@ ScValue *AdRegion::scGetProperty(const char *name) {
// Name
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Name") == 0) {
_scValue->setString(_name);
_scValue->setString(getName());
return _scValue;
}
@ -347,7 +347,7 @@ const char *AdRegion::scToString() {
//////////////////////////////////////////////////////////////////////////
bool AdRegion::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "REGION {\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "BLOCKED=%s\n", _blocked ? "TRUE" : "FALSE");
buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE");

View File

@ -486,11 +486,11 @@ bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) {
switch (obj->_type) {
case UI_BUTTON:
if (scumm_stricmp(obj->_name, "prev") == 0) {
if (scumm_stricmp(obj->getName(), "prev") == 0) {
_scrollOffset--;
} else if (scumm_stricmp(obj->_name, "next") == 0) {
} else if (scumm_stricmp(obj->getName(), "next") == 0) {
_scrollOffset++;
} else if (scumm_stricmp(obj->_name, "response") == 0) {
} else if (scumm_stricmp(obj->getName(), "response") == 0) {
if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD);
handleResponse(_responses[param2]);
_waitingScript = NULL;

View File

@ -1346,7 +1346,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
const char *LayerName = val->getString();
bool LayerFound = false;
for (int i = 0; i < _layers.getSize(); i++) {
if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) {
if (scumm_stricmp(LayerName, _layers[i]->getName()) == 0) {
stack->pushNative(_layers[i], true);
LayerFound = true;
break;
@ -1396,7 +1396,7 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
} else {
const char *nodeName = val->getString();
for (int i = 0; i < _objects.getSize(); i++) {
if (_objects[i] && _objects[i]->_name && scumm_stricmp(_objects[i]->_name, nodeName) == 0) {
if (_objects[i] && _objects[i]->getName() && scumm_stricmp(_objects[i]->getName(), nodeName) == 0) {
ret = _objects[i];
break;
}
@ -1962,7 +1962,7 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "SCENE {\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
if (_persistentState)
@ -2424,8 +2424,8 @@ BaseObject *AdScene::getNodeByName(const char *name) {
AdLayer *layer = _layers[i];
for (int j = 0; j < layer->_nodes.getSize(); j++) {
AdSceneNode *node = layer->_nodes[j];
if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->_name)) ||
(node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->_name))) {
if ((node->_type == OBJECT_ENTITY && !scumm_stricmp(name, node->_entity->getName())) ||
(node->_type == OBJECT_REGION && !scumm_stricmp(name, node->_region->getName()))) {
switch (node->_type) {
case OBJECT_ENTITY:
ret = node->_entity;
@ -2443,14 +2443,14 @@ BaseObject *AdScene::getNodeByName(const char *name) {
// free entities
for (int i = 0; i < _objects.getSize(); i++) {
if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->_name)) {
if (_objects[i]->_type == OBJECT_ENTITY && !scumm_stricmp(name, _objects[i]->getName())) {
return _objects[i];
}
}
// waypoint groups
for (int i = 0; i < _waypointGroups.getSize(); i++) {
if (!scumm_stricmp(name, _waypointGroups[i]->_name)) {
if (!scumm_stricmp(name, _waypointGroups[i]->getName())) {
return _waypointGroups[i];
}
}
@ -2489,7 +2489,7 @@ bool AdScene::persistState(bool saving) {
switch (node->_type) {
case OBJECT_ENTITY:
if (!node->_entity->_saveState) continue;
nodeState = state->getNodeState(node->_entity->_name, saving);
nodeState = state->getNodeState(node->_entity->getName(), saving);
if (nodeState) {
nodeState->transferEntity(node->_entity, _persistentStateSprites, saving);
//if(Saving) NodeState->_active = node->_entity->_active;
@ -2498,7 +2498,7 @@ bool AdScene::persistState(bool saving) {
break;
case OBJECT_REGION:
if (!node->_region->_saveState) continue;
nodeState = state->getNodeState(node->_region->_name, saving);
nodeState = state->getNodeState(node->_region->getName(), saving);
if (nodeState) {
if (saving) nodeState->_active = node->_region->_active;
else node->_region->_active = nodeState->_active;
@ -2515,7 +2515,7 @@ bool AdScene::persistState(bool saving) {
for (int i = 0; i < _objects.getSize(); i++) {
if (!_objects[i]->_saveState) continue;
if (_objects[i]->_type == OBJECT_ENTITY) {
nodeState = state->getNodeState(_objects[i]->_name, saving);
nodeState = state->getNodeState(_objects[i]->getName(), saving);
if (nodeState) {
nodeState->transferEntity((AdEntity *)_objects[i], _persistentStateSprites, saving);
//if(Saving) NodeState->_active = _objects[i]->_active;
@ -2526,7 +2526,7 @@ bool AdScene::persistState(bool saving) {
// waypoint groups
for (int i = 0; i < _waypointGroups.getSize(); i++) {
nodeState = state->getNodeState(_waypointGroups[i]->_name, saving);
nodeState = state->getNodeState(_waypointGroups[i]->getName(), saving);
if (nodeState) {
if (saving) nodeState->_active = _waypointGroups[i]->_active;
else _waypointGroups[i]->_active = nodeState->_active;

View File

@ -71,7 +71,7 @@ void AdSceneState::setFilename(const char *filename) {
//////////////////////////////////////////////////////////////////////////
AdNodeState *AdSceneState::getNodeState(char *name, bool saving) {
AdNodeState *AdSceneState::getNodeState(const char *name, bool saving) {
for (int i = 0; i < _nodeStates.getSize(); i++) {
if (scumm_stricmp(_nodeStates[i]->_name, name) == 0) return _nodeStates[i];
}

View File

@ -37,7 +37,7 @@ namespace WinterMute {
class AdNodeState;
class AdSceneState : public BaseClass {
public:
AdNodeState *getNodeState(char *name, bool saving);
AdNodeState *getNodeState(const char *name, bool saving);
void setFilename(const char *filename);
DECLARE_PERSISTENT(AdSceneState, BaseClass)
AdSceneState(BaseGame *inGame);

View File

@ -260,7 +260,7 @@ BaseSprite *AdSpriteSet::getSprite(TDirection direction) {
//////////////////////////////////////////////////////////////////////////
bool AdSpriteSet::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "SPRITESET {\n");
if (_name) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
if (getName()) buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
for (int i = 0; i < NUM_DIRECTIONS; i++) {
if (_sprites[i]) {
switch (i) {

View File

@ -75,7 +75,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) {
if (_animSprite) {
bool res = _animSprite->loadFile(_forcedTalkAnimName);
if (DID_FAIL(res)) {
_gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", _name, _forcedTalkAnimName);
_gameRef->LOG(res, "AdTalkHolder::GetTalkStance: error loading talk sprite (object:\"%s\" sprite:\"%s\")", getName(), _forcedTalkAnimName);
delete _animSprite;
_animSprite = NULL;
} else return _animSprite;
@ -86,7 +86,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) {
if (stance != NULL) {
// search special talk stances
for (int i = 0; i < _talkSpritesEx.getSize(); i++) {
if (scumm_stricmp(_talkSpritesEx[i]->_name, stance) == 0) {
if (scumm_stricmp(_talkSpritesEx[i]->getName(), stance) == 0) {
ret = _talkSpritesEx[i];
break;
}
@ -94,7 +94,7 @@ BaseSprite *AdTalkHolder::getTalkStance(const char *stance) {
if (ret == NULL) {
// serach generic talk stances
for (int i = 0; i < _talkSprites.getSize(); i++) {
if (scumm_stricmp(_talkSprites[i]->_name, stance) == 0) {
if (scumm_stricmp(_talkSprites[i]->getName(), stance) == 0) {
ret = _talkSprites[i];
break;
}

View File

@ -165,7 +165,7 @@ bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) {
//////////////////////////////////////////////////////////////////////////
bool AdWaypointGroup::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "WAYPOINTS {\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE");
buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint);

View File

@ -395,8 +395,7 @@ bool BaseGame::cleanup() {
_viewportStack.removeAll();
_viewportSP = -1;
delete[] _name;
_name = NULL;
setName(NULL);
setFilename(NULL);
for (int i = 0; i < 7; i++) {
delete[] _caption[i];
@ -1780,7 +1779,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int fileNum = 0;
while (true) {
sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum);
sprintf(filename, "%s%03d.bmp", Val->isNULL() ? getName() : Val->getString(), fileNum);
if (!Common::File::exists(filename))
break;
fileNum++;
@ -2160,7 +2159,7 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// Name
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Name") == 0) {
_scValue->setString(_name);
_scValue->setString(getName());
return _scValue;
}
//////////////////////////////////////////////////////////////////////////
@ -4346,7 +4345,7 @@ bool BaseGame::displayDebugInfo() {
sprintf(str, "Timer: %d", _timer);
_gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT);
if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT);
if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT);
sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024));
_systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT);

View File

@ -57,6 +57,10 @@ BaseNamedObject::~BaseNamedObject(void) {
//////////////////////////////////////////////////////////////////////
void BaseNamedObject::setName(const char *name) {
delete[] _name;
_name = NULL;
if (name == NULL)
return;
_name = new char [strlen(name) + 1];
if (_name != NULL) strcpy(_name, name);

View File

@ -35,13 +35,14 @@
namespace WinterMute {
class BaseNamedObject : public BaseClass {
char *_name;
public:
BaseNamedObject(BaseGame *inGame);
BaseNamedObject();
virtual ~BaseNamedObject(void);
BaseNamedObject(TDynamicConstructor, TDynamicConstructor);
char *_name;
const char *getName() { return _name; }
void setName(const char *name);
};

View File

@ -212,7 +212,7 @@ bool BasePersistenceManager::initSave(const char *desc) {
// new in ver 2
putDWORD((uint32)DCGF_VER_BUILD);
putString(_gameRef->_name);
putString(_gameRef->getName());
// thumbnail data size
bool thumbnailOK = false;
@ -314,7 +314,7 @@ bool BasePersistenceManager::initLoad(const char *filename) {
}
_saving = false;
if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) {
if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) {
_gameRef->LOG(0, "ERROR: Saved game name doesn't match current game");
cleanup();
return STATUS_FAILED;

View File

@ -324,7 +324,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) {
// Name
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Name") == 0) {
_scValue->setString(_name);
_scValue->setString(getName());
return _scValue;
}
@ -381,7 +381,7 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n
if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n");
else buffer->putTextIndent(indent, "%s {\n", nameOverride);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE");
buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint);

View File

@ -227,7 +227,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) {
// Name
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Name") == 0) {
_scValue->setString(_name);
_scValue->setString(getName());
return _scValue;
}
@ -272,7 +272,14 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_filename));
persistMgr->transfer(TMEMBER(_freezable));
persistMgr->transfer(TMEMBER(_name));
if (persistMgr->_saving) {
const char *name = getName();
persistMgr->transfer(TMEMBER(name));
} else {
const char *name;
persistMgr->transfer(TMEMBER(name));
setName(name);
}
_scripts.persist(persistMgr);
return STATUS_OK;
@ -284,7 +291,7 @@ bool BaseScriptHolder::addScript(const char *filename) {
for (int i = 0; i < _scripts.getSize(); i++) {
if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) {
if (_scripts[i]->_state != SCRIPT_FINISHED) {
_gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name);
_gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName());
return STATUS_OK;
}
}
@ -456,9 +463,9 @@ ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) {
//////////////////////////////////////////////////////////////////////////
void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) {
strcpy(buf, scToString());
if (_name && strcmp(_name, "<unnamed>") != 0) {
if (getName() && strcmp(getName(), "<unnamed>") != 0) {
strcat(buf, " Name: ");
strcat(buf, _name);
strcat(buf, getName());
}
if (_filename) {
strcat(buf, " File: ");

View File

@ -428,7 +428,7 @@ bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float
//////////////////////////////////////////////////////////////////////////
bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "SPRITE {\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE");
buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE");
buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE");

View File

@ -367,7 +367,7 @@ PartForce *PartEmitter::addForceByName(const char *name) {
PartForce *force = NULL;
for (int i = 0; i < _forces.getSize(); i++) {
if (scumm_stricmp(name, _forces[i]->_name) == 0) {
if (scumm_stricmp(name, _forces[i]->getName()) == 0) {
force = _forces[i];
break;
}
@ -402,7 +402,7 @@ bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int pos
//////////////////////////////////////////////////////////////////////////
bool PartEmitter::removeForce(const char *name) {
for (int i = 0; i < _forces.getSize(); i++) {
if (scumm_stricmp(name, _forces[i]->_name) == 0) {
if (scumm_stricmp(name, _forces[i]->getName()) == 0) {
delete _forces[i];
_forces.removeAt(i);
return STATUS_OK;

View File

@ -48,7 +48,14 @@ PartForce::~PartForce(void) {
//////////////////////////////////////////////////////////////////////////
bool PartForce::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_name));
if (persistMgr->_saving) {
const char *name = getName();
persistMgr->transfer(TMEMBER(name));
} else {
const char *name;
persistMgr->transfer(TMEMBER(name));
setName(name);
}
persistMgr->transfer(TMEMBER(_pos));
persistMgr->transfer(TMEMBER(_direction));
persistMgr->transfer(TMEMBER_INT(_type));

View File

@ -442,7 +442,7 @@ bool UIButton::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "BUTTON\n");
buffer->putTextIndent(indent, "{\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "\n");
@ -656,7 +656,7 @@ bool UIButton::display(int offsetX, int offsetY) {
void UIButton::press() {
applyEvent("Press");
if (_listenerObject) _listenerObject->listen(_listenerParamObject, _listenerParamDWORD);
if (_parentNotify && _parent) _parent->applyEvent(_name);
if (_parentNotify && _parent) _parent->applyEvent(getName());
_oneTimePress = false;
}

View File

@ -302,7 +302,7 @@ bool UIEdit::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "EDIT\n");
buffer->putTextIndent(indent, "{\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "\n");
@ -799,7 +799,7 @@ int UIEdit::deleteChars(int start, int end) {
delete[] _text;
_text = str;
}
if (_parentNotify && _parent) _parent->applyEvent(_name);
if (_parentNotify && _parent) _parent->applyEvent(getName());
return end - start;
}
@ -824,7 +824,7 @@ int UIEdit::insertChars(int pos, byte *chars, int num) {
delete[] _text;
_text = str;
}
if (_parentNotify && _parent) _parent->applyEvent(_name);
if (_parentNotify && _parent) _parent->applyEvent(getName());
return num;
}

View File

@ -177,7 +177,7 @@ bool UIEntity::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "ENTITY_CONTAINER\n");
buffer->putTextIndent(indent, "{\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "\n");

View File

@ -240,7 +240,7 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else {
const char *findName = val->getString();
for (i = 0; i < win->_widgets.getSize(); i++) {
if (scumm_stricmp(win->_widgets[i]->_name, findName) == 0) {
if (scumm_stricmp(win->_widgets[i]->getName(), findName) == 0) {
found = true;
break;
}
@ -332,7 +332,7 @@ ScValue *UIObject::scGetProperty(const char *name) {
// Name
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Name") == 0) {
_scValue->setString(_name);
_scValue->setString(getName());
return _scValue;
}

View File

@ -296,7 +296,7 @@ bool UIText::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "STATIC\n");
buffer->putTextIndent(indent, "{\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "\n");

View File

@ -578,7 +578,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "WINDOW\n");
buffer->putTextIndent(indent, "{\n");
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name);
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
buffer->putTextIndent(indent + 2, "\n");
@ -679,7 +679,7 @@ bool UIWindow::saveAsText(BaseDynamicBuffer *buffer, int indent) {
//////////////////////////////////////////////////////////////////////////
bool UIWindow::enableWidget(const char *name, bool Enable) {
for (int i = 0; i < _widgets.getSize(); i++) {
if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_disable = !Enable;
if (scumm_stricmp(_widgets[i]->getName(), name) == 0) _widgets[i]->_disable = !Enable;
}
return STATUS_OK;
}
@ -688,7 +688,7 @@ bool UIWindow::enableWidget(const char *name, bool Enable) {
//////////////////////////////////////////////////////////////////////////
bool UIWindow::showWidget(const char *name, bool Visible) {
for (int i = 0; i < _widgets.getSize(); i++) {
if (scumm_stricmp(_widgets[i]->_name, name) == 0) _widgets[i]->_visible = Visible;
if (scumm_stricmp(_widgets[i]->getName(), name) == 0) _widgets[i]->_visible = Visible;
}
return STATUS_OK;
}
@ -710,7 +710,7 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else stack->pushNative(_widgets[widget], true);
} else {
for (int i = 0; i < _widgets.getSize(); i++) {
if (scumm_stricmp(_widgets[i]->_name, val->getString()) == 0) {
if (scumm_stricmp(_widgets[i]->getName(), val->getString()) == 0) {
stack->pushNative(_widgets[i], true);
return STATUS_OK;
}
@ -1280,7 +1280,7 @@ bool UIWindow::listen(BaseScriptHolder *param1, uint32 param2) {
switch (obj->_type) {
case UI_BUTTON:
if (scumm_stricmp(obj->_name, "close") == 0) close();
if (scumm_stricmp(obj->getName(), "close") == 0) close();
else return BaseObject::listen(param1, param2);
break;
default: