예제 #1
0
bool Game::cop_isObjectNotIntersectingBox() {
	debug(DBG_OPCODES, "Game::cop_isObjectNotIntersectingBox()");
	int16 var1A = _objectScript.fetchNextWord();
	int var18 = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (var18 != -1) {
		SceneObject *so = derefSceneObject(var18);
		if (so->statePrev != 0) {
			int16 var1E = getObjectTransformXPos(var18);
			int16 var22 = getObjectTransformYPos(var18);
			var18 = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
			if (var18 != -1) {
				so = derefSceneObject(var18);
				if (so->statePrev != 0) {
					int16 var20 = getObjectTransformXPos(var18);
					int16 var24 = getObjectTransformYPos(var18);
					bool foundBox = false;
					for (int i = 0; i < _boxesCountTable[var1A]; ++i) {
						if (intersectsBox(var1A, i, var1E, var22, var20, var24)) {
							foundBox = true;
							break;
						}
					}
					if (foundBox) {
						if (var18 == _objectScript.testObjectNum) {
							_objectScript.dataOffset = _objectScript.testDataOffset;
							assert(0); // XXX
							return true;
						}
						return false;
					}
					foundBox = false;
					for (int i = 0; i < _boxesCountTable[10 + var1A]; ++i) {
						if (intersectsBox(10 + var1A, i, var1E, var22, var20, var24)) {
							foundBox = true;
							break;
						}
					}
					if (foundBox) {
						if (var18 == _objectScript.testObjectNum) {
							_objectScript.dataOffset = _objectScript.testDataOffset;
							assert(0); // XXX
							return true;
						}
						return false;
					}
					return true;
				}
			}
		}
	}
	if (var18 == _objectScript.testObjectNum) {
		_objectScript.dataOffset = _objectScript.testDataOffset;
		assert(0); // XXX
		return true;
	}
	return false;
}
예제 #2
0
void Game::oop_addObjectToBag() {
	debug(DBG_OPCODES, "Game::oop_addObjectToBag()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		if (findBagObjectByName(so->name) == -1) {
			assert(_bagObjectsCount < NUM_BAG_OBJECTS);
			BagObject *bo = &_bagObjectsTable[_bagObjectsCount];
			strcpy(bo->name, so->name);

			SceneObjectFrame *sof = &_sceneObjectFramesTable[so->frameNumPrev];
			uint32 size = sof->hdr.w * sof->hdr.h + 4;
			bo->data = (uint8 *)malloc(size);
			if (bo->data) {
				bo->dataSize = decodeLzss(sof->data, bo->data);
				assert(bo->dataSize == size);
			}

			++_bagObjectsCount;
			if (_bagObjectsCount != 0 && _currentBagObject == -1) {
				_currentBagObject = 0;
			}
		}
	}
}
예제 #3
0
bool Game::cop_testMotionNum() {
	debug(DBG_OPCODES, "Game::cop_testMotionNum");
	bool ret = true;
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	if (ret) {
		SceneObject *so = derefSceneObject(index);
		if (so->statePrev != 0) {
			int16 _dx = so->motionNum2 - _animationsTable[_sceneObjectMotionsTable[so->motionNum1].animNum].firstMotionIndex;
			int16 _ax = 0;
			if (_objectScript.objectFound) {
				if (_sceneObjectMotionsTable[so->motionNum1].animNum != _sceneObjectMotionsTable[so->motionInit].animNum) {
					_ax = _animationsTable[_sceneObjectMotionsTable[so->motionNum1].animNum].unk26;
				}
			}
			if (testExpr(_ax + _dx + 1)) {
				return true;
			}
		}
		if (index == _objectScript.testObjectNum) {
			_objectScript.dataOffset = _objectScript.testDataOffset;
			assert(0); // XXX
		} else {
			ret = false;
		}
	}
	return ret;
}
예제 #4
0
bool Game::cop_testObjectMotionYPos() {
	debug(DBG_OPCODES, "Game::cop_testObjectMotionYPos()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		int num = so->motionNum + so->motionInit;
		int16 var1A = _sceneObjectMotionsTable[num].firstFrameIndex + so->motionFrameNum;
		int _ax = so->yPrev - so->yInit;
		_ax -= _sceneObjectFramesTable[so->frameNumPrev].hdr.yPos;
		_ax += _sceneObjectFramesTable[var1A].hdr.yPos;
		int16 div = _objectScript.fetchNextWord();
		var1A = _ax % div;
		if (var1A < 0) {
			var1A += div;
		}
		int16 cmp = _objectScript.fetchNextWord();
		if (var1A == cmp && so->state == 1) {
			return true;
		}
		if (index == _objectScript.testObjectNum) {
			assert(0);
			_objectScript.dataOffset = _objectScript.testDataOffset;
			return true;
		}
	} else {
		_objectScript.dataOffset += 4;
	}
	return false;
}
예제 #5
0
bool Game::cop_isObjectNotInBox() {
	debug(DBG_OPCODES, "Game::cop_isObjectNotInBox()");
	bool ret = true;
	int16 var1A = _objectScript.fetchNextWord(); // boxNum
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound); // var18
	if (index == -1) {
		ret = false;
	}
	if (ret) {
		SceneObject *so = derefSceneObject(index);
		if (so->statePrev != 0) {
			int16 var1E = getObjectTransformXPos(index);
			int16 var20 = getObjectTransformXPos(index);
			int16 var22 = getObjectTransformYPos(index);
			int16 var24 = getObjectTransformYPos(index);
			bool foundBox = false;
			for (int i = 0; i < _boxesCountTable[var1A]; ++i) {
				Box *box = derefBox(var1A, i);
				if (boxInRect(box, var1E, var20, var22, var24) && box->state == 1) {
					foundBox = true;
					break;
				}
			}
			if (foundBox) {
				if (index == _objectScript.testObjectNum) {
					_objectScript.dataOffset = _objectScript.testDataOffset;
					assert(0); // XXX
				} else {
					ret = false;
				}
				return ret;
			}
			foundBox = false;
			for (int i = 0; i < _boxesCountTable[10 + var1A]; ++i) {
				Box *box = derefBox(10 + var1A, i);
				if (boxInRect(box, var1E, var20, var22, var24) && box->state == 1) {
					foundBox = true;
					break;
				}
			}
			if (foundBox) {
				if (index == _objectScript.testObjectNum) {
					_objectScript.dataOffset = _objectScript.testDataOffset;
					assert(0); // XXX
				} else {
					ret = false;
				}
				return ret;
			}
			return true;
		}
	}
	if (index == _objectScript.testObjectNum) {
		_objectScript.dataOffset = _objectScript.testDataOffset;
		assert(0); // XXX
	} else {
		ret = false;
	}
	return ret;
}
예제 #6
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimCommandIssueFieldChanged::redo()
{
    RiaApplication* app = RiaApplication::instance();
    PdmObject* project = app->project();

    caf::PdmObjectHandle* pdmObject = findObjectByName(project, this->objectName);

    if (pdmObject)
    {
        caf::PdmFieldHandle* fieldHandle = findFieldByKeyword(pdmObject, this->fieldName);

        if (fieldHandle && fieldHandle->uiCapability())
        {
            caf::PdmValueField* valueField = dynamic_cast<caf::PdmValueField*>(fieldHandle);
            CVF_ASSERT(valueField);

            QVariant oldValue = valueField->toQVariant();
            QVariant newValue(this->fieldValueToApply);

            valueField->setFromQVariant(newValue);

            caf::PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
            uiFieldHandle->notifyFieldChanged(oldValue, newValue);
        }
    }
}
예제 #7
0
bool Game::cop_isObjectInRect() {
	debug(DBG_OPCODES, "Game::cop_isObjectInRect");
	bool ret = true;
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	int16 var1E = _objectScript.fetchNextWord(); // x1
	int16 var22 = _objectScript.fetchNextWord(); // y1
	int16 var20 = _objectScript.fetchNextWord(); // x2
	int16 var24 = _objectScript.fetchNextWord(); // y2
	assert(var1E <= var20);
	assert(var22 <= var24);
	if (ret) {
		SceneObject *so = derefSceneObject(index);
		if (so->state != 0) {
			int xObj = so->xPrev + _sceneObjectFramesTable[so->frameNumPrev].hdr.w;
			if (xObj >= var1E && so->xPrev <= var20) {
				int yObj = so->yPrev + _sceneObjectFramesTable[so->frameNumPrev].hdr.h;
				if (yObj >= var22 && so->yPrev <= var24) {
					return ret;
				}
			}
		}
		if (index == _objectScript.testObjectNum) {
			_objectScript.dataOffset = _objectScript.testDataOffset;
			assert(0); // XXX
		} else {
			ret = false;
		}
	}
	return ret;
}
예제 #8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimCommandIssueFieldChanged::findObjectByName(caf::PdmObjectHandle* pdmObject, const QString& objectName)
{
    std::vector<caf::PdmFieldHandle*> fields;
    pdmObject->fields(fields);

    caf::PdmUiObjectHandle* uiObjectHandle = uiObj(pdmObject);

    if (uiObjectHandle && uiObjectHandle->uiName() == objectName)
    {
        return pdmObject;
    }
    
    for (size_t fIdx = 0; fIdx < fields.size(); fIdx++)
    {
        if (fields[fIdx])
        {
            std::vector<caf::PdmObjectHandle*> children;
            fields[fIdx]->childObjects(&children);

            for (size_t cIdx = 0; cIdx < children.size(); cIdx++)
            {
                PdmObjectHandle* candidateObj = findObjectByName(children[cIdx], objectName);
                if (candidateObj)
                {
                    return candidateObj;
                }
            }
        }
    }

    return NULL;
}
예제 #9
0
bool Game::cop_testObjectAndObjectYPos() {
	debug(DBG_OPCODES, "Game::cop_testObjectAndObjectYPos()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		if (so->statePrev != 0) {
			int16 var22 = getObjectTransformYPos(index);
			int16 var24 = getObjectTransformYPos(index);
			int var18 = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
			if (var18 != -1) {
				so = derefSceneObject(var18);
				if (so->statePrev == 0) {
					if (var18 == _objectScript.testObjectNum) {
						assert(0);
						_objectScript.dataOffset = _objectScript.testDataOffset;
						return true;
					}
					return false;
				}
				int16 var1E = getObjectTransformYPos(var18);
				int16 var20 = getObjectTransformYPos(var18);
				int16 _dx = MIN(var22, var24);
				int16 _ax = MAX(var1E, var20);
				if (_dx <= _ax) {
					_dx = MAX(var22, var24);
					_ax = MIN(var1E, var20);
					if (_dx >= _ax) {
						return true;
					}
				}
				if (index == _objectScript.testObjectNum || var18 == _objectScript.testObjectNum) {
					assert(0);
					_objectScript.dataOffset = _objectScript.testDataOffset;
					return true;
				}
			}
			return false;
		}
		if (index == _objectScript.testObjectNum) {
			assert(0);
			_objectScript.dataOffset = _objectScript.testDataOffset;
			return true;
		}
	}
	return false;
}
예제 #10
0
void Game::oop_setupObjectPos_023() {
	debug(DBG_OPCODES, "Game::oop_setupObjectPos_023()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		setupObjectPos(_objectScript.currentObjectNum, index, _objectScript.objectFound, 0, 2, 3);
	} else {
		_objectScript.dataOffset += 18;
	}
}
예제 #11
0
void Game::oop_adjustObjectPos_1v0000() {
	debug(DBG_OPCODES, "Game::oop_adjustObjectPos_1v0000()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		int16 a0 = _objectScript.fetchNextWord();
		changeObjectMotionFrame(_objectScript.currentObjectNum, index, _objectScript.objectFound, 1, a0, 0, 0, 0, 0);
	} else {
		_objectScript.dataOffset += 2;
	}
}
예제 #12
0
void Game::oop_setObjectFlip() {
	debug(DBG_OPCODES, "Game::oop_setObjectFlip()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		so->flip = _objectScript.fetchNextWord();
	} else {
		_objectScript.dataOffset += 2;
	}
}
예제 #13
0
void Game::oop_evalObjectZ() {
	debug(DBG_OPCODES, "Game::oop_evalObjectZ()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		evalExpr(&so->z);
	} else {
		_objectScript.dataOffset += 4;
	}
}
예제 #14
0
void Game::oop_resetObjectCel() {
	debug(DBG_OPCODES, "Game::oop_resetObjectCel()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		so->motionNum = _objectScript.fetchNextWord() - 1;
		so->motionFrameNum = 0;
	} else {
		_objectScript.dataOffset += 2;
	}
}
예제 #15
0
void Game::oop_setObjectTransformInitPos() {
	debug(DBG_OPCODES, "Game::oop_setObjectTransformInitPos()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		so->xInit = getObjectTransformXPos(_objectScript.currentObjectNum);
		so->yInit = getObjectTransformYPos(_objectScript.currentObjectNum);
	} else {
		_objectScript.dataOffset += 12;
	}
}
예제 #16
0
void Game::oop_evalObjectVar() {
	debug(DBG_OPCODES, "Game::oop_evalObjectVar()");
	int var = _objectScript.fetchNextWord();
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		assert(var >= 0 && var < 10);
		SceneObject *so = derefSceneObject(index);
		evalExpr(&so->varsTable[var]);
	} else {
		_objectScript.dataOffset += 4;
	}
}
예제 #17
0
void Game::oop_setObjectMode() {
	debug(DBG_OPCODES, "Game::oop_setObjectMode()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	int mode = _objectScript.fetchNextWord();
	int modeRndMul = 0;
	if (mode == 2) {
		modeRndMul = _objectScript.fetchNextWord();
	}
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		so->mode = mode;
		if (mode == 2) {
			so->modeRndMul = modeRndMul;
		}
	}
}
예제 #18
0
void Game::oop_translateObjectYPos() {
	debug(DBG_OPCODES, "Game::oop_translateObjectYPos()");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		int16 a0 = _objectScript.fetchNextWord();
		int16 a2 = _objectScript.fetchNextWord();
		int16 a4 = _objectScript.fetchNextWord();
		int16 a6 = _objectScript.fetchNextWord();
		int16 var1A = getObjectTranslateYPos(index, a0, a2, a4);
		if (a2 / 2 >= var1A) {
			so->y -= MIN<int16>(a6, var1A);
		} else {
			so->y += MIN<int16>(a6, a2 - var1A);
		}
	} else {
		_objectScript.dataOffset += 8;
	}
}
예제 #19
0
bool Game::cop_isObjectInScene() {
	debug(DBG_OPCODES, "Game::cop_isObjectInScene");
	bool ret = true;
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	if (ret) { // FIXME: not present in the original disassembly
		if (index != _objectScript.currentObjectNum) {
			if (index == _objectScript.testObjectNum) {
				_objectScript.dataOffset = _objectScript.testDataOffset;
				assert(0); // XXX
			} else {
				ret = false;
			}
		}
	}
	return ret;
}
예제 #20
0
void Game::oop_initializeObject() {
	debug(DBG_OPCODES, "Game::oop_initializeObject");
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		int16 op = _objectScript.fetchNextWord();
		if (op == 0) {
			if (so->state != 0) {
				so->x = so->xPrev;
				so->y = so->yPrev;
				so->frameNum = so->frameNumPrev;
				if (so->state == 2) {
					SceneObjectFrame *sof = derefSceneObjectFrame(so->frameNum);
					copyBufferToBuffer(so->x, _bitmapBuffer1.h + 1 - so->y - sof->hdr.h, sof->hdr.w, sof->hdr.h, &_bitmapBuffer3, &_bitmapBuffer1);
				}
				so->state = -1;
			}
		} else if (op == 1) {
			int16 mode = so->mode;
			so->mode = 1;
			reinitializeObject(index);
			so->mode = mode;
			if (so->state == 2) {
				so->state = 1;
			}
		} else if (op == 2) {
			if (so->state == 1) {
				so->x = so->xPrev;
				so->y = so->yPrev;
				so->frameNum = so->frameNumPrev;
				so->state = 2;
			} else {
				int16 mode = so->mode;
				so->mode = 3;
				reinitializeObject(index);
				so->mode = mode;
			}
		}
	} else {
		_objectScript.dataOffset += 2;
	}
}
예제 #21
0
bool Game::cop_testObjectTransformYPos() {
	debug(DBG_OPCODES, "Game::cop_testObjectTransformYPos");
	bool ret = true;
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	if (ret && derefSceneObject(index)->state != 0) {
		if (!compareObjectTransformYPos(index)) {
			if (index == _objectScript.testObjectNum) {
				_objectScript.dataOffset = _objectScript.testDataOffset;
				assert(0); // XXX
			} else {
				ret = false;
			}
		}
	} else {
		_objectScript.dataOffset += 14;
	}
	return ret;
}
예제 #22
0
void Game::oop_setBoxToObject() {
	debug(DBG_OPCODES, "Game::oop_setBoxToObject()");
	int16 var1A = _objectScript.fetchNextWord();
	int16 var1C = _objectScript.fetchNextWord();
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index != -1) {
		SceneObject *so = derefSceneObject(index);
		if (so->statePrev != 0) {
			int16 var1E = getObjectTransformXPos(index);
			int16 var20 = getObjectTransformXPos(index);
			int16 var22 = getObjectTransformYPos(index);
			int16 var24 = getObjectTransformYPos(index);
			Box *box = derefBox(var1A, var1C);
			box->x1 = MIN(var1E, var20);
			box->x2 = MAX(var1E, var20);
			box->y1 = MIN(var24, var22);
			box->y2 = MAX(var24, var22);
			return;
		}
	}
	_objectScript.dataOffset += 24;
}
예제 #23
0
bool Game::cop_testObjectFlip() {
	debug(DBG_OPCODES, "Game::cop_testObjectFlip");
	bool ret = true;
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	if (ret) {
		SceneObject *so = derefSceneObject(index);
		int16 flip = _objectScript.fetchNextWord();
		if (flip != so->flip) {
			if (index == _objectScript.testObjectNum) {
				_objectScript.dataOffset = _objectScript.testDataOffset;
				assert(0); // XXX
			} else {
				ret = false;
			}
		}
	} else {
		_objectScript.dataOffset += 2;
	}
	return ret;
}
예제 #24
0
bool Game::cop_testObjectVar() {
	debug(DBG_OPCODES, "Game::cop_testObjectVar()");
	bool ret = true;
	int var = _objectScript.fetchNextWord();
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	if (ret) {
		SceneObject *so = derefSceneObject(index);
		assert(var >= 0 && var < 10);
		if (!testExpr(so->varsTable[var])) {
			if (index == _objectScript.testObjectNum) {
				_objectScript.dataOffset = _objectScript.testDataOffset;
				assert(0); // XXX
			} else {
				ret = false;
			}
		}
//_logExpr = false;
	}
	return ret;
}
예제 #25
0
bool Game::cop_testObjectFrameNum() {
	debug(DBG_OPCODES, "Game::cop_testObjectFrameNum");
	bool ret = true;
	int index = findObjectByName(_objectScript.currentObjectNum, _objectScript.testObjectNum, &_objectScript.objectFound);
	if (index == -1) {
		ret = false;
	}
	if (ret) {
		SceneObject *so = derefSceneObject(index);
		if (so->statePrev != 0) {
			int16 val = so->frameNum - _sceneObjectMotionsTable[so->motionNum2].firstFrameIndex + 1;
			if (testExpr(val)) {
				return true;
			}
		}
		if (index == _objectScript.testObjectNum) {
			_objectScript.dataOffset = _objectScript.testDataOffset;
			assert(0); // XXX
		} else {
			ret = false;
		}
	}
	return ret;
}