diff options
author | Vladimir Menshakov | 2009-11-07 08:35:24 +0000 |
---|---|---|
committer | Vladimir Menshakov | 2009-11-07 08:35:24 +0000 |
commit | aaeafde32530607a253304fd6e966727886cdf12 (patch) | |
tree | 9ea22a1515be4e6006c0007fd8f86ba22402cc0e | |
parent | f534c12289cca1152fc57545aeab12d5973720ed (diff) | |
download | scummvm-rg350-aaeafde32530607a253304fd6e966727886cdf12.tar.gz scummvm-rg350-aaeafde32530607a253304fd6e966727886cdf12.tar.bz2 scummvm-rg350-aaeafde32530607a253304fd6e966727886cdf12.zip |
"constify" dump and save methods, added intersects_hline/intersects_vline
svn-id: r45715
-rw-r--r-- | engines/teenagent/objects.cpp | 15 | ||||
-rw-r--r-- | engines/teenagent/objects.h | 20 |
2 files changed, 22 insertions, 13 deletions
diff --git a/engines/teenagent/objects.cpp b/engines/teenagent/objects.cpp index 0ddcbf54fe..d7f2967483 100644 --- a/engines/teenagent/objects.cpp +++ b/engines/teenagent/objects.cpp @@ -38,7 +38,7 @@ void Rect::load(byte * src) { bottom = ins.readUint16LE(); } -void Rect::save() { +void Rect::save() const { assert(_base != NULL); Common::MemoryWriteStream outs(_base, 8); outs.writeUint16LE(left); @@ -71,7 +71,7 @@ void Object::load(byte * src) { description = parse_description((const char *)src); } -void Object::save() { +void Object::save() const { assert(_base != NULL); rect.save(); @@ -86,7 +86,7 @@ void Object::setName(const Common::String &new_name) { name = new_name; } -void Object::dump() { +void Object::dump() const { debug(0, "object: %u %u [%u,%u,%u,%u], actor: [%u,%u,%u,%u], orientation: %u, name: %s", id, enabled, rect.left, rect.top, rect.right, rect.bottom, actor_rect.left, actor_rect.top, actor_rect.right, actor_rect.bottom, @@ -140,9 +140,9 @@ void UseHotspot::load(byte *src) { callback = in.readUint16LE(); } -void Walkbox::dump() { +void Walkbox::dump() const { debug(0, "walkbox %02x %02x [%d, %d, %d, %d] %02x %02x %02x %02x ", - unk00, orientation, + type, orientation, rect.left, rect.right, rect.top, rect.bottom, unk0a, unk0b, unk0c, unk0d); } @@ -150,7 +150,7 @@ void Walkbox::dump() { void Walkbox::load(byte *src) { _base = src; - unk00 = *src++; + type = *src++; orientation = *src++; rect.load(src); src += 8; @@ -160,8 +160,9 @@ void Walkbox::load(byte *src) { unk0d = *src++; } -void Walkbox::save() { +void Walkbox::save() const { assert(_base != NULL); + _base[0] = type; _base[1] = orientation; rect.save(); } diff --git a/engines/teenagent/objects.h b/engines/teenagent/objects.h index ecd1dd71e9..545f5f7c2b 100644 --- a/engines/teenagent/objects.h +++ b/engines/teenagent/objects.h @@ -61,7 +61,15 @@ struct Rect { } void load(byte *src); //8 bytes - void save(); + void save() const; + + inline bool intersects_hline(int x1, int x2, int y) const { + return x1 < right && x2 > left && y >= top && y < bottom; + } + + inline bool intersects_vline(int x, int y1, int y2) const { + return y1 < bottom && y2 > top && x >= left && x < right; + } protected: byte * _base; @@ -79,10 +87,10 @@ struct Object { Common::String name, description; Object(): _base(NULL) {} - void dump(); + void dump() const; void setName(const Common::String &name); void load(byte *addr); - void save(); + void save() const; static Common::String parse_description(const char *name); @@ -112,7 +120,7 @@ struct UseHotspot { }; struct Walkbox { - byte unk00; + byte type; byte orientation; Rect rect; byte unk0a; @@ -121,9 +129,9 @@ struct Walkbox { byte unk0d; Walkbox() : _base(NULL) {} - void dump(); + void dump() const; void load(byte *src); - void save(); + void save() const; protected: byte * _base; |