00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029 #include "contain.h"
00030 #include "gamewin.h"
00031 #include "gamemap.h"
00032 #include "chunks.h"
00033 #include "cheat.h"
00034 #include "databuf.h"
00035 #include "ucsched.h"
00036 #include "Gump_manager.h"
00037
00038 using std::ostream;
00039
00040
00041
00042
00043
00044 void Ireg_game_object::paint
00045 (
00046 )
00047 {
00048 int x, y;
00049 gwin->get_shape_location(this, x, y);
00050 if (flags & (1L << Obj_flags::invisible))
00051 paint_invisible(x, y);
00052 else
00053 paint_shape(x, y);
00054 }
00055
00056
00057
00058
00059
00060
00061 void Ireg_game_object::move
00062 (
00063 int newtx,
00064 int newty,
00065 int newlift
00066 )
00067 {
00068 if (owner)
00069 {
00070 owner->remove(this);
00071 set_invalid();
00072 }
00073 Game_object::move(newtx, newty, newlift);
00074 }
00075
00076
00077
00078
00079
00080
00081 void Ireg_game_object::remove_this
00082 (
00083 int nodel
00084 )
00085 {
00086 if (owner)
00087 owner->remove(this);
00088 else
00089 {
00090 Map_chunk *chunk = gmap->get_chunk_safely(cx, cy);
00091 if (chunk)
00092 chunk->remove(this);
00093 }
00094 if (!nodel)
00095 {
00096 cheat.clear_this_grabbed_actor((Actor*)this);
00097 gwin->delete_object(this);
00098 }
00099 }
00100
00101
00102
00103
00104
00105 int Ireg_game_object::is_dragable
00106 (
00107 ) const
00108 {
00109
00110 return get_info().get_weight() > 0;
00111 }
00112
00113
00114
00115
00116
00117 void Ireg_game_object::write_ireg
00118 (
00119 DataSource *out
00120 )
00121 {
00122 unsigned char buf[11];
00123 buf[0] = 10;
00124 write_common_ireg(&buf[1]);
00125 buf[5] = (get_lift()&15)<<4;
00126 buf[6] = get_quality();
00127 Shape_info& info = get_info();
00128 if (info.has_quality_flags())
00129 {
00130 buf[6] = get_flag((Obj_flags::invisible) != 0) +
00131 ((get_flag(Obj_flags::okay_to_take) != 0) << 3);
00132 }
00133
00134 else if (get_flag(Obj_flags::okay_to_take) && info.has_quantity())
00135 buf[6] |= 0x80;
00136
00137 buf[7] = (get_flag(Obj_flags::is_temporary) != 0);
00138 out->write((char*)buf, sizeof(buf));
00139
00140 Game_map::write_scheduled(out, this);
00141 }
00142
00143
00144 int Ireg_game_object::get_ireg_size()
00145 {
00146
00147 if (gumpman->find_gump(this) || Usecode_script::find(this))
00148 return -1;
00149
00150 return 11;
00151 }