ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/object.h
(Generate patch)

Comparing deliantra/server/include/object.h (file contents):
Revision 1.68 by root, Mon Dec 25 11:25:49 2006 UTC vs.
Revision 1.80 by pippijn, Sat Jan 6 14:42:30 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2001 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
240 */ 241 */
241 object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ 242 object *ACC (RW, more); /* Pointer to the rest of a large body of objects */
242 object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different 243 object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different
243 client_container *seen_by; // seen by which player/container currently? 244 client_container *seen_by; // seen by which player/container currently?
244 245
245 static vector active; // active objects, not yet used 246 //static vector active_list; // active objects, not yet used
246 static vector objects; // not used yet, use first->next->... 247 //static vector object_list; // not used yet, use first->next->...
247 static object *first; // will be replaced by "objects" 248 static object *first; // will be replaced by "objects"
248 249
249 static object *create (); 250 MTH static object *create ();
250 void copy_to (object *dst); 251 MTH void copy_to (object *dst);
251 object *clone (); // create + copy_to 252 MTH object *clone (); // create + copy_to
252 void do_destroy (); 253 void do_destroy ();
253 void gather_callbacks (AV *&callbacks, event_type event) const; 254 void gather_callbacks (AV *&callbacks, event_type event) const;
254 void destroy (bool destroy_inventory = false); 255 MTH void destroy (bool destroy_inventory = false);
255 256
256 // recursively destroy all objects in inventory, optionally dropping them to the ground instead 257 // recursively destroy all objects in inventory, optionally dropping them to the ground instead
257 void destroy_inv (bool drop_to_ground = false); 258 MTH void destroy_inv (bool drop_to_ground = false);
258 void remove (); 259 MTH void remove ();
259 object *insert (object *item); // insert into inventory 260 MTH object *insert (object *item); // insert into inventory
260 261
261 static bool can_merge_slow (object *op1, object *op2); 262 static bool can_merge_slow (object *op1, object *op2);
262 263
263 // this is often used in time-critical code, so optimise 264 // this is often used in time-critical code, so optimise
264 static bool can_merge (object *op1, object *op2) 265 MTH static bool can_merge (object *op1, object *op2)
265 { 266 {
266 return op1->value == op2->value 267 return op1->value == op2->value
267 && op1->name == op2->name 268 && op1->name == op2->name
268 && can_merge_slow (op1, op2); 269 && can_merge_slow (op1, op2);
269 } 270 }
270 271
271 void set_owner (object *owner); 272 MTH void set_owner (object *owner);
273 MTH void set_speed (float speed);
272 274
273 void instantiate () 275 MTH void instantiate ()
274 { 276 {
275 if (!uuid.seq) // HACK 277 if (!uuid.seq) // HACK
276 uuid = gen_uuid (); 278 uuid = gen_uuid ();
277 279
278 attachable::instantiate (); 280 attachable::instantiate ();
279 } 281 }
280 282
281 // recalculate all stats 283 // recalculate all stats
282 void update_stats (); 284 MTH void update_stats ();
283 void roll_stats (); 285 MTH void roll_stats ();
284 void swap_stats (int a, int b); 286 MTH void swap_stats (int a, int b);
285 void add_statbonus (); 287 MTH void add_statbonus ();
286 void remove_statbonus (); 288 MTH void remove_statbonus ();
287 void drain_stat (); 289 MTH void drain_stat ();
288 void drain_specific_stat (int deplete_stats); 290 MTH void drain_specific_stat (int deplete_stats);
289 void change_luck (int value); 291 MTH void change_luck (int value);
290 292
291 // info must hold 256 * 3 bytes currently 293 // info must hold 256 * 3 bytes currently
292 const char *debug_desc (char *info) const; 294 const char *debug_desc (char *info) const;
293 const char *debug_desc () const; 295 MTH const char *debug_desc () const;
296 const char *flag_desc (char *desc, int len) const;
294 297
295 bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } 298 MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; }
296 bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET 299 MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET
297 || type == CLOAK || type == BOOTS || type == GLOVES 300 || type == CLOAK || type == BOOTS || type == GLOVES
298 || type == BRACERS || type == GIRDLE; } 301 || type == BRACERS || type == GIRDLE; }
299 bool is_alive () const { return (type == PLAYER 302 MTH bool is_alive () const { return (type == PLAYER
300 || flag [FLAG_MONSTER] 303 || flag [FLAG_MONSTER]
301 || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) 304 || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR))
302 && !flag [FLAG_IS_A_TEMPLATE]; } 305 && !flag [FLAG_IS_A_TEMPLATE]; }
303 bool is_arrow () const { return type == ARROW 306 MTH bool is_arrow () const { return type == ARROW
304 || (type == SPELL_EFFECT 307 || (type == SPELL_EFFECT
305 && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } 308 && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); }
309
310 MTH bool has_active_speed () const { return FABS(speed) >= MIN_ACTIVE_SPEED; }
311
312 // temporary: wether the object can be saved in a map file
313 // contr => is a player
314 // head => only save head of a multitile object
315 // owner => can not reference owner yet
316 MTH bool can_map_save () const { return !contr && !head && !owner; }
306 317
307 /* This return true if object has still randomitems which 318 /* This return true if object has still randomitems which
308 * could be expanded. 319 * could be expanded.
309 */ 320 */
310 bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } 321 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; }
311 322
312 // returns the player that has this object in his inventory, or 0 323 // returns the player that has this object in his inventory, or 0
313 object *in_player () const 324 MTH object *in_player () const
314 { 325 {
315 for (object *op = env; op; op = op->env) 326 for (object *op = env; op; op = op->env)
316 if (op->type == PLAYER) 327 if (op->type == PLAYER)
317 return op; 328 return op;
318 329
319 return 0; 330 return 0;
320 } 331 }
332
333 // "temporary" helper function
334 MTH object *head_ ()
335 {
336 return head ? head : this;
337 }
338
339 // insert object at same map position as 'where'
340 // handles both inventory and map "positions"
341 MTH object *insert_at (object *where, object *originator = 0, int flags = 0);
342
343 MTH bool active () const;
344 MTH void activate ();
345 MTH void deactivate ();
346 MTH void activate_recursive ();
347 MTH void deactivate_recursive ();
348
349 // set the givne flag on all objects in the inventory recursively
350 MTH void set_flag_inv (int flag, int value = 1);
351
352 void enter_exit (object *exit);//PERL
353 MTH void enter_map (maptile *newmap, int x, int y);
321 354
322 // returns the mapspace this object is in 355 // returns the mapspace this object is in
323 mapspace &ms () const; 356 mapspace &ms () const;
324 357
325 // fully recursive iterator 358 // fully recursive iterator
335 operator object *() const { return item; } 368 operator object *() const { return item; }
336 369
337 object *operator ->() const { return item; } 370 object *operator ->() const { return item; }
338 object &operator * () const { return *item; } 371 object &operator * () const { return *item; }
339 }; 372 };
373
374 MTH unsigned int random_seed () const
375 {
376 return (unsigned int)uuid.seq;
377 }
340 378
341 // depth-first recursive iterator 379 // depth-first recursive iterator
342 struct depth_iterator : iterator_base 380 struct depth_iterator : iterator_base
343 { 381 {
344 depth_iterator (object *container); 382 depth_iterator (object *container);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines