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.35 by root, Sun Dec 10 01:16:27 2006 UTC vs.
Revision 1.39 by root, Tue Dec 12 20:53:02 2006 UTC

24 24
25#include <global.h> 25#include <global.h>
26#include <funcpoint.h> 26#include <funcpoint.h>
27 27
28#include <loader.h> 28#include <loader.h>
29#ifndef WIN32 /* ---win32 exclude header */
30# include <unistd.h> 29#include <unistd.h>
31#endif /* win32 */
32 30
33#include "path.h" 31#include "path.h"
34 32
35 33
36/* 34/*
157int 155int
158check_path (const char *name, int prepend_dir) 156check_path (const char *name, int prepend_dir)
159{ 157{
160 char buf[MAX_BUF]; 158 char buf[MAX_BUF];
161 159
162#ifndef WIN32
163 char *endbuf; 160 char *endbuf;
164 struct stat statbuf; 161 struct stat statbuf;
165 int mode = 0; 162 int mode = 0;
166#endif
167 163
168 if (prepend_dir) 164 if (prepend_dir)
169 strcpy (buf, create_pathname (name)); 165 strcpy (buf, create_pathname (name));
170 else 166 else
171 strcpy (buf, name); 167 strcpy (buf, name);
172#ifdef WIN32 /* ***win32: check this sucker in windows style. */
173 return (_access (buf, 0));
174#else
175 168
176 /* old method (strchr(buf, '\0')) seemd very odd to me - 169 /* old method (strchr(buf, '\0')) seemd very odd to me -
177 * this method should be equivalant and is clearer. 170 * this method should be equivalant and is clearer.
178 * Can not use strcat because we need to cycle through 171 * Can not use strcat because we need to cycle through
179 * all the names. 172 * all the names.
192 if ((statbuf.st_mode & S_IWGRP && getegid () == statbuf.st_gid) || 185 if ((statbuf.st_mode & S_IWGRP && getegid () == statbuf.st_gid) ||
193 (statbuf.st_mode & S_IWUSR && geteuid () == statbuf.st_uid) || (statbuf.st_mode & S_IWOTH)) 186 (statbuf.st_mode & S_IWUSR && geteuid () == statbuf.st_uid) || (statbuf.st_mode & S_IWOTH))
194 mode |= 2; 187 mode |= 2;
195 188
196 return (mode); 189 return (mode);
197#endif
198} 190}
199 191
200/* 192/*
201 * Prints out debug-information about a map. 193 * Prints out debug-information about a map.
202 * Dumping these at llevError doesn't seem right, but is 194 * Dumping these at llevError doesn't seem right, but is
600 SET_FLAG (otmp, FLAG_OBJ_ORIGINAL); 592 SET_FLAG (otmp, FLAG_OBJ_ORIGINAL);
601 } 593 }
602 } 594 }
603 } 595 }
604 596
605 free_object (op); 597 op->destroy (0);
606 link_multipart_objects (m); 598 link_multipart_objects (m);
607} 599}
608 600
609/* This saves all the objects on the map in a non destructive fashion. 601/* This saves all the objects on the map in a non destructive fashion.
610 * Modified by MSW 2001-07-01 to do in a single pass - reduces code, 602 * Modified by MSW 2001-07-01 to do in a single pass - reduces code,
860 852
861 while (fgets (buf, HUGE_BUF, fp) != NULL) 853 while (fgets (buf, HUGE_BUF, fp) != NULL)
862 { 854 {
863 buf[HUGE_BUF - 1] = 0; 855 buf[HUGE_BUF - 1] = 0;
864 key = buf; 856 key = buf;
857
865 while (isspace (*key)) 858 while (isspace (*key))
866 key++; 859 key++;
860
867 if (*key == 0) 861 if (*key == 0)
868 continue; /* empty line */ 862 continue; /* empty line */
863
869 value = strchr (key, ' '); 864 value = strchr (key, ' ');
865
870 if (!value) 866 if (!value)
871 { 867 {
872 end = strchr (key, '\n'); 868 if ((end = strchr (key, '\n')))
873 if (end != NULL)
874 {
875 *end = 0; 869 *end = 0;
876 }
877 } 870 }
878 else 871 else
879 { 872 {
880 *value = 0; 873 *value = 0;
881 value++; 874 value++;
882 end = strchr (value, '\n'); 875 end = strchr (value, '\n');
876
883 while (isspace (*value)) 877 while (isspace (*value))
884 { 878 {
885 value++; 879 value++;
880
886 if (*value == '\0' || value == end) 881 if (*value == '\0' || value == end)
887 { 882 {
888 /* Nothing but spaces. */ 883 /* Nothing but spaces. */
889 value = NULL; 884 value = NULL;
890 break; 885 break;
1313 if (op->head == NULL && (QUERY_FLAG (op, FLAG_UNIQUE) || unique)) 1308 if (op->head == NULL && (QUERY_FLAG (op, FLAG_UNIQUE) || unique))
1314 { 1309 {
1315 clean_object (op); 1310 clean_object (op);
1316 if (QUERY_FLAG (op, FLAG_IS_LINKED)) 1311 if (QUERY_FLAG (op, FLAG_IS_LINKED))
1317 remove_button_link (op); 1312 remove_button_link (op);
1318 remove_ob (op); 1313 op->remove ();
1319 free_object (op); 1314 op->destroy (0);
1320 } 1315 }
1321 } 1316 }
1322 } 1317 }
1323} 1318}
1324 1319
1427 print_shop_string (m, shop); 1422 print_shop_string (m, shop);
1428 fprintf (freezer, "shopitems %s\n", shop); 1423 fprintf (freezer, "shopitems %s\n", shop);
1429 } 1424 }
1430 if (m->shopgreed) 1425 if (m->shopgreed)
1431 fprintf (freezer, "shopgreed %f\n", m->shopgreed); 1426 fprintf (freezer, "shopgreed %f\n", m->shopgreed);
1432#ifndef WIN32
1433 if (m->shopmin) 1427 if (m->shopmin)
1434 fprintf (freezer, "shopmin %llu\n", m->shopmin); 1428 fprintf (freezer, "shopmin %llu\n", m->shopmin);
1435 if (m->shopmax) 1429 if (m->shopmax)
1436 fprintf (freezer, "shopmax %llu\n", m->shopmax); 1430 fprintf (freezer, "shopmax %llu\n", m->shopmax);
1437#else
1438 if (m->shopmin)
1439 fprintf (freezer, "shopmin %I64u\n", m->shopmin);
1440 if (m->shopmax)
1441 fprintf (freezer, "shopmax %I64u\n", m->shopmax);
1442#endif
1443 if (m->shoprace) 1431 if (m->shoprace)
1444 fprintf (freezer, "shoprace %s\n", m->shoprace); 1432 fprintf (freezer, "shoprace %s\n", m->shoprace);
1445 if (m->darkness) 1433 if (m->darkness)
1446 fprintf (freezer, "darkness %d\n", m->darkness); 1434 fprintf (freezer, "darkness %d\n", m->darkness);
1447 if (m->width) 1435 if (m->width)
1529 { 1517 {
1530 next = tmp->below; 1518 next = tmp->below;
1531 clean_object (tmp); 1519 clean_object (tmp);
1532 if (QUERY_FLAG (tmp, FLAG_IS_LINKED)) 1520 if (QUERY_FLAG (tmp, FLAG_IS_LINKED))
1533 remove_button_link (tmp); 1521 remove_button_link (tmp);
1534 remove_ob (tmp); 1522 tmp->remove ();
1535 free_object (tmp); 1523 tmp->destroy (0);
1536 } 1524 }
1537} 1525}
1538 1526
1539/* 1527/*
1540 * Remove and free all objects in the given map. 1528 * Remove and free all objects in the given map.
1565 /* If the map isn't in memory, free_object will remove and 1553 /* If the map isn't in memory, free_object will remove and
1566 * free objects in op's inventory. So let it do the job. 1554 * free objects in op's inventory. So let it do the job.
1567 */ 1555 */
1568 if (m->in_memory == MAP_IN_MEMORY) 1556 if (m->in_memory == MAP_IN_MEMORY)
1569 clean_object (op); 1557 clean_object (op);
1570 remove_ob (op); 1558 op->remove ();
1571 free_object (op); 1559 op->destroy (0);
1572 } 1560 }
1573 } 1561 }
1574} 1562}
1575 1563
1576/* 1564/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines