ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.166 by root, Wed Oct 21 00:44:39 2009 UTC vs.
Revision 1.167 by root, Thu Nov 5 15:43:21 2009 UTC

25#include <unistd.h> 25#include <unistd.h>
26 26
27#include "global.h" 27#include "global.h"
28#include "loader.h" 28#include "loader.h"
29#include "path.h" 29#include "path.h"
30
31//+GPL
30 32
31sint8 maptile::outdoor_darkness; 33sint8 maptile::outdoor_darkness;
32 34
33/* This rolls up wall, blocks_magic, blocks_view, etc, all into 35/* This rolls up wall, blocks_magic, blocks_view, etc, all into
34 * one function that just returns a P_.. value (see map.h) 36 * one function that just returns a P_.. value (see map.h)
242 // go through and calculate what all the containers are carrying. 244 // go through and calculate what all the containers are carrying.
243 //TODO: remove 245 //TODO: remove
244 container->update_weight (); 246 container->update_weight ();
245} 247}
246 248
249//-GPL
250
247void 251void
248maptile::set_object_flag (int flag, int value) 252maptile::set_object_flag (int flag, int value)
249{ 253{
250 if (!spaces) 254 if (!spaces)
251 return; 255 return;
265 269
266 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 270 for (mapspace *ms = spaces + size (); ms-- > spaces; )
267 for (object *tmp = ms->bot; tmp; tmp = tmp->above) 271 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
268 INVOKE_OBJECT (RESET, tmp); 272 INVOKE_OBJECT (RESET, tmp);
269} 273}
274
275//+GPL
270 276
271/* link_multipart_objects go through all the objects on the map looking 277/* link_multipart_objects go through all the objects on the map looking
272 * for objects whose arch says they are multipart yet according to the 278 * for objects whose arch says they are multipart yet according to the
273 * info we have, they only have the head (as would be expected when 279 * info we have, they only have the head (as would be expected when
274 * they are saved). 280 * they are saved).
301 else 307 else
302 op = op->above; 308 op = op->above;
303 } 309 }
304 } 310 }
305} 311}
312
313//-GPL
306 314
307/* 315/*
308 * Loads (ands parses) the objects into a given map from the specified 316 * Loads (ands parses) the objects into a given map from the specified
309 * file pointer. 317 * file pointer.
310 */ 318 */
471 if (spaces) 479 if (spaces)
472 return; 480 return;
473 481
474 spaces = salloc0<mapspace> (size ()); 482 spaces = salloc0<mapspace> (size ());
475} 483}
484
485//+GPL
476 486
477/* Takes a string from a map definition and outputs a pointer to the array of shopitems 487/* Takes a string from a map definition and outputs a pointer to the array of shopitems
478 * corresponding to that string. Memory is allocated for this, it must be freed 488 * corresponding to that string. Memory is allocated for this, it must be freed
479 * at a later date. 489 * at a later date.
480 * Called by parse_map_headers below. 490 * Called by parse_map_headers below.
583 } 593 }
584 594
585 return buf; 595 return buf;
586} 596}
587 597
598//-GPL
599
588/* This loads the header information of the map. The header 600/* This loads the header information of the map. The header
589 * contains things like difficulty, size, timeout, etc. 601 * contains things like difficulty, size, timeout, etc.
590 * this used to be stored in the map object, but with the 602 * this used to be stored in the map object, but with the
591 * addition of tiling, fields beyond that easily named in an 603 * addition of tiling, fields beyond that easily named in an
592 * object structure were needed, so it just made sense to 604 * object structure were needed, so it just made sense to
683 } 695 }
684 696
685 abort (); 697 abort ();
686} 698}
687 699
700//+GPL
701
688/****************************************************************************** 702/******************************************************************************
689 * This is the start of unique map handling code 703 * This is the start of unique map handling code
690 *****************************************************************************/ 704 *****************************************************************************/
691 705
692/* This goes through the maptile and removed any unique items on the map. */ 706/* This goes through the maptile and removed any unique items on the map. */
708 722
709 op = above; 723 op = above;
710 } 724 }
711 } 725 }
712} 726}
727
728//-GPL
713 729
714bool 730bool
715maptile::_save_header (object_freezer &freezer) 731maptile::_save_header (object_freezer &freezer)
716{ 732{
717#define MAP_OUT(k) freezer.put (KW_ ## k, k) 733#define MAP_OUT(k) freezer.put (KW_ ## k, k)
774 if (!_save_header (freezer)) 790 if (!_save_header (freezer))
775 return false; 791 return false;
776 792
777 return freezer.save (path); 793 return freezer.save (path);
778} 794}
795
796//+GPL
779 797
780/* 798/*
781 * Remove and free all objects in the given map. 799 * Remove and free all objects in the given map.
782 */ 800 */
783void 801void
1522 int dx, dy; 1540 int dx, dy;
1523 1541
1524 return adjacent_map (op1->map, op2->map, &dx, &dy); 1542 return adjacent_map (op1->map, op2->map, &dx, &dy);
1525} 1543}
1526 1544
1545//-GPL
1546
1527object * 1547object *
1528maptile::insert (object *op, int x, int y, object *originator, int flags) 1548maptile::insert (object *op, int x, int y, object *originator, int flags)
1529{ 1549{
1530 return insert_ob_in_map_at (op, this, originator, flags, x, y); 1550 return insert_ob_in_map_at (op, this, originator, flags, x, y);
1531} 1551}
1542 if (default_region) 1562 if (default_region)
1543 return default_region; 1563 return default_region;
1544 1564
1545 return ::region::default_region (); 1565 return ::region::default_region ();
1546} 1566}
1567
1568//+GPL
1547 1569
1548/* picks a random object from a style map. 1570/* picks a random object from a style map.
1549 */ 1571 */
1550object * 1572object *
1551maptile::pick_random_object (rand_gen &gen) const 1573maptile::pick_random_object (rand_gen &gen) const
1567 1589
1568 // instead of crashing in the unlikely(?) case, try to return *something* 1590 // instead of crashing in the unlikely(?) case, try to return *something*
1569 return archetype::find ("bug"); 1591 return archetype::find ("bug");
1570} 1592}
1571 1593
1594//-GPL
1595
1572void 1596void
1573maptile::play_sound (faceidx sound, int x, int y) const 1597maptile::play_sound (faceidx sound, int x, int y) const
1574{ 1598{
1575 if (!sound) 1599 if (!sound)
1576 return; 1600 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines