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.60 by root, Sun Dec 31 10:28:35 2006 UTC vs.
Revision 1.64 by root, Mon Jan 1 12:28:45 2007 UTC

36 * it really should be called create_mapname 36 * it really should be called create_mapname
37 */ 37 */
38const char * 38const char *
39create_pathname (const char *name) 39create_pathname (const char *name)
40{ 40{
41 static char buf[MAX_BUF]; 41 static char buf[8192];
42
43 /* Why? having extra / doesn't confuse unix anyplace? Dependancies
44 * someplace else in the code? msw 2-17-97
45 */
46 if (*name == '/')
47 sprintf (buf, "%s/%s%s", settings.datadir, settings.mapdir, name);
48 else
49 sprintf (buf, "%s/%s/%s", settings.datadir, settings.mapdir, name); 42 snprintf (buf, sizeof (buf), "%s/%s/%s", settings.datadir, settings.mapdir, name);
50 return (buf); 43 return buf;
51}
52
53/*
54 * same as create_pathname, but for the overlay maps.
55 */
56const char *
57create_overlay_pathname (const char *name)
58{
59 static char buf[MAX_BUF];
60
61 /* Why? having extra / doesn't confuse unix anyplace? Dependancies
62 * someplace else in the code? msw 2-17-97
63 */
64 if (*name == '/')
65 sprintf (buf, "%s/%s%s", settings.localdir, settings.mapdir, name);
66 else
67 sprintf (buf, "%s/%s/%s", settings.localdir, settings.mapdir, name);
68 return (buf);
69}
70
71/*
72 * same as create_pathname, but for the template maps.
73 */
74const char *
75create_template_pathname (const char *name)
76{
77 static char buf[MAX_BUF];
78
79 /* Why? having extra / doesn't confuse unix anyplace? Dependancies
80 * someplace else in the code? msw 2-17-97
81 */
82 if (*name == '/')
83 sprintf (buf, "%s/%s%s", settings.localdir, settings.templatedir, name);
84 else
85 sprintf (buf, "%s/%s/%s", settings.localdir, settings.templatedir, name);
86 return (buf);
87}
88
89/*
90 * This makes absolute path to the itemfile where unique objects
91 * will be saved. Converts '/' to '@'. I think it's essier maintain
92 * files than full directory structure, but if this is problem it can
93 * be changed.
94 */
95static const char *
96create_items_path (const char *s)
97{
98 static char buf[MAX_BUF];
99 char *t;
100
101 if (*s == '/')
102 s++;
103
104 sprintf (buf, "%s/%s/", settings.localdir, settings.uniquedir);
105
106 for (t = buf + strlen (buf); *s; s++, t++)
107 if (*s == '/')
108 *t = '@';
109 else
110 *t = *s;
111 *t = 0;
112 return (buf);
113} 44}
114 45
115/* 46/*
116 * This function checks if a file with the given path exists. 47 * This function checks if a file with the given path exists.
117 * -1 is returned if it fails, otherwise the mode of the file 48 * -1 is returned if it fails, otherwise the mode of the file
398 * carrying. 329 * carrying.
399 */ 330 */
400 sum_weight (container); 331 sum_weight (container);
401} 332}
402 333
334void
335maptile::set_object_flag (int flag, int value)
336{
337 if (!spaces)
338 return;
339
340 for (mapspace *ms = spaces + size (); ms-- > spaces; )
341 for (object *tmp = ms->bot; tmp; tmp = tmp->above)
342 tmp->flag [flag] = value;
343}
344
403/* link_multipart_objects go through all the objects on the map looking 345/* link_multipart_objects go through all the objects on the map looking
404 * for objects whose arch says they are multipart yet according to the 346 * for objects whose arch says they are multipart yet according to the
405 * info we have, they only have the head (as would be expected when 347 * info we have, they only have the head (as would be expected when
406 * they are saved). We do have to look for the old maps that did save 348 * they are saved). We do have to look for the old maps that did save
407 * the more sections and not re-add sections for them. 349 * the more sections and not re-add sections for them.
528 if (!spaces) 470 if (!spaces)
529 return; 471 return;
530 472
531 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 473 for (mapspace *ms = spaces + size (); ms-- > spaces; )
532 for (object *op = ms->bot; op; op = op->above) 474 for (object *op = ms->bot; op; op = op->above)
533 op->activate (1); 475 op->activate_recursive ();
534} 476}
535 477
536void 478void
537maptile::deactivate () 479maptile::deactivate ()
538{ 480{
539 if (!spaces) 481 if (!spaces)
540 return; 482 return;
541 483
542 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 484 for (mapspace *ms = spaces + size (); ms-- > spaces; )
543 for (object *op = ms->bot; op; op = op->above) 485 for (object *op = ms->bot; op; op = op->above)
544 op->deactivate (1); 486 op->deactivate_recursive ();
545} 487}
546 488
547bool 489bool
548maptile::save_objects (object_freezer &freezer, int flags) 490maptile::save_objects (object_freezer &freezer, int flags)
549{ 491{
789 keyword kw = thawer.get_kv (); 731 keyword kw = thawer.get_kv ();
790 732
791 switch (kw) 733 switch (kw)
792 { 734 {
793 case KW_EOF: 735 case KW_EOF:
794 LOG (llevError, "%s: end of file while reading map header, aborting header load.", &path); 736 LOG (llevError, "%s: end of file while reading map header, aborting header load.\n", &path);
795 return false; 737 return false;
796 738
797 case KW_end: 739 case KW_end:
798 return true; 740 return true;
799 741
957 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); 899 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]);
958 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); 900 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]);
959 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); 901 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]);
960 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); 902 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]);
961 903
962 MAP_OUT2 (end, 0); 904 freezer.put (this);
905 freezer.put (KW_end);
963 906
964 return true; 907 return true;
965} 908}
966 909
967bool 910bool

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines