本文整理汇总了C++中ScValue::isInt方法的典型用法代码示例。如果您正苦于以下问题:C++ ScValue::isInt方法的具体用法?C++ ScValue::isInt怎么用?C++ ScValue::isInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScValue
的用法示例。
在下文中一共展示了ScValue::isInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BaseScriptable
SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
_string = nullptr;
_capacity = 0;
stack->correctParams(1);
ScValue *val = stack->pop();
if (val->isInt()) {
_capacity = MAX(0, val->getInt());
if (_capacity > 0) {
_string = new char[_capacity];
memset(_string, 0, _capacity);
}
} else {
setStringVal(val->getString());
}
if (_capacity == 0) {
setStringVal("");
}
}
示例2: scCallMethod
//.........这里部分代码省略.........
// RemoveAttachment
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveAttachment") == 0) {
stack->correctParams(1);
ScValue *val = stack->pop();
bool found = false;
if (val->isNative()) {
BaseScriptable *obj = val->getNative();
for (uint32 i = 0; i < _attachmentsPre.size(); i++) {
if (_attachmentsPre[i] == obj) {
found = true;
_gameRef->unregisterObject(_attachmentsPre[i]);
_attachmentsPre.remove_at(i);
i--;
}
}
for (uint32 i = 0; i < _attachmentsPost.size(); i++) {
if (_attachmentsPost[i] == obj) {
found = true;
_gameRef->unregisterObject(_attachmentsPost[i]);
_attachmentsPost.remove_at(i);
i--;
}
}
} else {
const char *attachmentName = val->getString();
for (uint32 i = 0; i < _attachmentsPre.size(); i++) {
if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) {
found = true;
_gameRef->unregisterObject(_attachmentsPre[i]);
_attachmentsPre.remove_at(i);
i--;
}
}
for (uint32 i = 0; i < _attachmentsPost.size(); i++) {
if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) {
found = true;
_gameRef->unregisterObject(_attachmentsPost[i]);
_attachmentsPost.remove_at(i);
i--;
}
}
}
stack->pushBool(found);
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetAttachment
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetAttachment") == 0) {
stack->correctParams(1);
ScValue *val = stack->pop();
AdObject *ret = nullptr;
if (val->isInt()) {
int index = val->getInt();
int currIndex = 0;
for (uint32 i = 0; i < _attachmentsPre.size(); i++) {
if (currIndex == index) {
ret = _attachmentsPre[i];
}
currIndex++;
}
for (uint32 i = 0; i < _attachmentsPost.size(); i++) {
if (currIndex == index) {
ret = _attachmentsPost[i];
}
currIndex++;
}
} else {
const char *attachmentName = val->getString();
for (uint32 i = 0; i < _attachmentsPre.size(); i++) {
if (_attachmentsPre[i]->getName() && scumm_stricmp(_attachmentsPre[i]->getName(), attachmentName) == 0) {
ret = _attachmentsPre[i];
break;
}
}
if (!ret) {
for (uint32 i = 0; i < _attachmentsPost.size(); i++) {
if (_attachmentsPost[i]->getName() && scumm_stricmp(_attachmentsPost[i]->getName(), attachmentName) == 0) {
ret = _attachmentsPre[i];
break;
}
}
}
}
if (ret != nullptr) {
stack->pushNative(ret, true);
} else {
stack->pushNULL();
}
return STATUS_OK;
} else {
return BaseObject::scCallMethod(script, stack, thisStack, name);
}
}