Made is_object() a method of the segment manager

svn-id: r44042
This commit is contained in:
Filippos Karapetis 2009-09-12 17:42:04 +00:00
parent 358b5649ce
commit 15cb36a7ee
5 changed files with 13 additions and 20 deletions

View File

@ -224,16 +224,6 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
*/
char *kernel_lookup_text(EngineState *s, reg_t address, int index);
/******************** Debug functionality ********************/
/**
* Checks whether a heap address contains an object
* @param s The current state
* @parm obj The address to check
* @return True if it is an object, false otherwise
*/
bool is_object(SegManager *segMan, reg_t obj);
/******************** Kernel function parameter macros ********************/
/* Returns the parameter value or (alt) if not enough parameters were supplied */

View File

@ -805,7 +805,7 @@ reg_t kCanBeHere(EngineState *s, int, int argc, reg_t *argv) {
while (widget) {
if (widget->_ID && (widget->signal & _K_VIEW_SIG_FLAG_STOPUPD)
&& ((widget->_ID != obj.segment) || (widget->_subID != obj.offset))
&& is_object(s->segMan, make_reg(widget->_ID, widget->_subID)))
&& s->segMan->isObject(make_reg(widget->_ID, widget->_subID)))
if (collides_with(s, abs_zone, make_reg(widget->_ID, widget->_subID), 1, GASEOUS_VIEW_MASK_ACTIVE, argc, argv))
return not_register(s, NULL_REG);
@ -831,7 +831,7 @@ reg_t kCanBeHere(EngineState *s, int, int argc, reg_t *argv) {
reg_t other_obj = node->value;
debugC(2, kDebugLevelBresen, " comparing against %04x:%04x\n", PRINT_REG(other_obj));
if (!is_object(s->segMan, other_obj)) {
if (!s->segMan->isObject(other_obj)) {
warning("CanBeHere() cliplist contains non-object %04x:%04x", PRINT_REG(other_obj));
} else if (other_obj != obj) { // Clipping against yourself is not recommended
@ -1674,7 +1674,7 @@ static void draw_rect_to_control_map(EngineState *s, Common::Rect abs_zone) {
static void draw_obj_to_control_map(EngineState *s, GfxDynView *view) {
reg_t obj = make_reg(view->_ID, view->_subID);
if (!is_object(s->segMan, obj))
if (!s->segMan->isObject(obj))
warning("View %d does not contain valid object reference %04x:%04x", view->_ID, PRINT_REG(obj));
reg_t* sp = view->signalp.getPointer(s->segMan);
@ -1780,7 +1780,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
reg_t obj = make_reg(widget->_ID, widget->_subID);
reg_t under_bits = NULL_REG;
if (!is_object(s->segMan, obj)) {
if (!s->segMan->isObject(obj)) {
error("Non-object %04x:%04x present in view list during delete time", PRINT_REG(obj));
obj = NULL_REG;
} else {
@ -1798,7 +1798,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
}
}
}
if (is_object(segMan, obj)) {
if (segMan->isObject(obj)) {
if (invoke_selector(INV_SEL(obj, delete_, kContinueOnInvalidSelector), 0))
warning("Object at %04x:%04x requested deletion, but does not have a delete funcselector", PRINT_REG(obj));
if (_k_animate_ran) {

View File

@ -107,10 +107,6 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
return 0;
}
bool is_object(SegManager *segMan, reg_t object) {
return segMan->getObject(object) != NULL;
}
// Loads arbitrary resources of type 'restype' with resource numbers 'resnrs'
// This implementation ignores all resource numbers except the first one.
reg_t kLoad(EngineState *s, int, int argc, reg_t *argv) {

View File

@ -165,7 +165,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
while ((result = s->_sound.sfx_poll(&handle, &cue))) {
reg_t obj = DEFROBNICATE_HANDLE(handle);
if (!is_object(s->segMan, obj)) {
if (!s->segMan->isObject(obj)) {
warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
return;
}

View File

@ -352,6 +352,13 @@ public:
*/
Object *getObject(reg_t pos);
/**
* Checks whether a heap address contains an object
* @parm obj The address to check
* @return True if it is an object, false otherwise
*/
bool isObject(reg_t obj) { return getObject(obj) != NULL; }
/**
* Determines the name of an object
* @param[in] pos Location (segment, offset) of the object