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.62 by root, Sun Dec 31 22:23:11 2006 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
528 if (!spaces) 459 if (!spaces)
529 return; 460 return;
530 461
531 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 462 for (mapspace *ms = spaces + size (); ms-- > spaces; )
532 for (object *op = ms->bot; op; op = op->above) 463 for (object *op = ms->bot; op; op = op->above)
533 op->activate (1); 464 op->activate_recursive ();
534} 465}
535 466
536void 467void
537maptile::deactivate () 468maptile::deactivate ()
538{ 469{
539 if (!spaces) 470 if (!spaces)
540 return; 471 return;
541 472
542 for (mapspace *ms = spaces + size (); ms-- > spaces; ) 473 for (mapspace *ms = spaces + size (); ms-- > spaces; )
543 for (object *op = ms->bot; op; op = op->above) 474 for (object *op = ms->bot; op; op = op->above)
544 op->deactivate (1); 475 op->deactivate_recursive ();
545} 476}
546 477
547bool 478bool
548maptile::save_objects (object_freezer &freezer, int flags) 479maptile::save_objects (object_freezer &freezer, int flags)
549{ 480{
789 keyword kw = thawer.get_kv (); 720 keyword kw = thawer.get_kv ();
790 721
791 switch (kw) 722 switch (kw)
792 { 723 {
793 case KW_EOF: 724 case KW_EOF:
794 LOG (llevError, "%s: end of file while reading map header, aborting header load.", &path); 725 LOG (llevError, "%s: end of file while reading map header, aborting header load.\n", &path);
795 return false; 726 return false;
796 727
797 case KW_end: 728 case KW_end:
798 return true; 729 return true;
799 730
957 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); 888 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]); 889 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]); 890 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]); 891 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]);
961 892
962 MAP_OUT2 (end, 0); 893 freezer.put (KW_end);
963 894
964 return true; 895 return true;
965} 896}
966 897
967bool 898bool

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines