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.42 by root, Wed Dec 13 02:55:49 2006 UTC vs.
Revision 1.44 by root, Mon Dec 18 04:07:30 2006 UTC

27 27
28#include <loader.h> 28#include <loader.h>
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include "path.h" 31#include "path.h"
32
33 32
34/* 33/*
35 * Returns the maptile which has a name matching the given argument. 34 * Returns the maptile which has a name matching the given argument.
36 * return NULL if no match is found. 35 * return NULL if no match is found.
37 */ 36 */
730 char *shop_string, *p, *q, *next_semicolon, *next_colon; 729 char *shop_string, *p, *q, *next_semicolon, *next_colon;
731 shopitems *items = NULL; 730 shopitems *items = NULL;
732 int i = 0, number_of_entries = 0; 731 int i = 0, number_of_entries = 0;
733 const typedata *current_type; 732 const typedata *current_type;
734 733
735 shop_string = strdup_local (input_string); 734 shop_string = strdup (input_string);
736 p = shop_string; 735 p = shop_string;
737 /* first we'll count the entries, we'll need that for allocating the array shortly */ 736 /* first we'll count the entries, we'll need that for allocating the array shortly */
738 while (p) 737 while (p)
739 { 738 {
740 p = strchr (p, ';'); 739 p = strchr (p, ';');
926 * with nothing between). There is no reason in those cases to 925 * with nothing between). There is no reason in those cases to
927 * keep the empty message. Also, msgbuf contains garbage data 926 * keep the empty message. Also, msgbuf contains garbage data
928 * when msgpos is zero, so copying it results in crashes 927 * when msgpos is zero, so copying it results in crashes
929 */ 928 */
930 if (msgpos != 0) 929 if (msgpos != 0)
931 m->msg = strdup_local (msgbuf); 930 m->msg = strdup (msgbuf);
932 } 931 }
933 else if (!strcmp (key, "maplore")) 932 else if (!strcmp (key, "maplore"))
934 { 933 {
935 while (fgets (buf, HUGE_BUF, fp) != NULL) 934 while (fgets (buf, HUGE_BUF, fp) != NULL)
936 { 935 {
942 strcpy (maplorebuf + maplorepos, buf); 941 strcpy (maplorebuf + maplorepos, buf);
943 maplorepos += strlen (buf); 942 maplorepos += strlen (buf);
944 } 943 }
945 } 944 }
946 if (maplorepos != 0) 945 if (maplorepos != 0)
947 m->maplore = strdup_local (maplorebuf); 946 m->maplore = strdup (maplorebuf);
948 } 947 }
949 else if (!strcmp (key, "end")) 948 else if (!strcmp (key, "end"))
950 { 949 {
951 break; 950 break;
952 } 951 }
961 LOG (llevError, "loading map and got a non 'arch map' line(%s %s)?\n", key, value); 960 LOG (llevError, "loading map and got a non 'arch map' line(%s %s)?\n", key, value);
962 } 961 }
963 else if (!strcmp (key, "name")) 962 else if (!strcmp (key, "name"))
964 { 963 {
965 *end = 0; 964 *end = 0;
966 m->name = strdup_local (value); 965 m->name = strdup (value);
967 } 966 }
968 /* first strcmp value on these are old names supported 967 /* first strcmp value on these are old names supported
969 * for compatibility reasons. The new values (second) are 968 * for compatibility reasons. The new values (second) are
970 * what really should be used. 969 * what really should be used.
971 */ 970 */
1009 else if (!strcmp (key, "shopmax")) 1008 else if (!strcmp (key, "shopmax"))
1010 m->shopmax = atol (value); 1009 m->shopmax = atol (value);
1011 else if (!strcmp (key, "shoprace")) 1010 else if (!strcmp (key, "shoprace"))
1012 { 1011 {
1013 *end = 0; 1012 *end = 0;
1014 m->shoprace = strdup_local (value); 1013 m->shoprace = strdup (value);
1015 } 1014 }
1016 else if (!strcmp (key, "outdoor")) 1015 else if (!strcmp (key, "outdoor"))
1017 m->outdoor = atoi (value); 1016 m->outdoor = atoi (value);
1018 else if (!strcmp (key, "temp")) 1017 else if (!strcmp (key, "temp"))
1019 m->temp = atoi (value); 1018 m->temp = atoi (value);
1069 } 1068 }
1070 1069
1071 if (editor) 1070 if (editor)
1072 { 1071 {
1073 /* Use the value as in the file. */ 1072 /* Use the value as in the file. */
1074 m->tile_path[tile - 1] = strdup_local (value); 1073 m->tile_path[tile - 1] = strdup (value);
1075 } 1074 }
1076 else if (path != NULL) 1075 else if (path != NULL)
1077 { 1076 {
1078 /* Use the normalized value. */ 1077 /* Use the normalized value. */
1079 m->tile_path[tile - 1] = strdup_local (path); 1078 m->tile_path[tile - 1] = strdup (path);
1080 } 1079 }
1081 } /* end if tile direction (in)valid */ 1080 } /* end if tile direction (in)valid */
1082 } 1081 }
1083 else 1082 else
1084 LOG (llevError, "Got unknown value in map header: %s %s\n", key, value); 1083 LOG (llevError, "Got unknown value in map header: %s %s\n", key, value);
1343 make_path_to_file (filename); 1342 make_path_to_file (filename);
1344 } 1343 }
1345 else 1344 else
1346 { 1345 {
1347 if (!m->tmpname) 1346 if (!m->tmpname)
1348 m->tmpname = tempnam_local (settings.tmpdir, NULL); 1347 m->tmpname = tempnam (settings.tmpdir, NULL);
1349 1348
1350 strcpy (filename, m->tmpname); 1349 strcpy (filename, m->tmpname);
1351 } 1350 }
1352 1351
1353 LOG (llevDebug, "Saving map %s to %s\n", m->path, filename); 1352 LOG (llevDebug, "Saving map %s to %s\n", m->path, filename);
1639 last->next = m->next; 1638 last->next = m->next;
1640 1639
1641 delete m; 1640 delete m;
1642} 1641}
1643 1642
1644
1645
1646/* 1643/*
1647 * Makes sure the given map is loaded and swapped in. 1644 * Makes sure the given map is loaded and swapped in.
1648 * name is path name of the map. 1645 * name is path name of the map.
1649 * flags meaning: 1646 * flags meaning:
1650 * 0x1 (MAP_FLUSH): flush the map - always load from the map directory, 1647 * 0x1 (MAP_FLUSH): flush the map - always load from the map directory,
1652 * 0x2 (MAP_PLAYER_UNIQUE) - this is a unique map for each player. 1649 * 0x2 (MAP_PLAYER_UNIQUE) - this is a unique map for each player.
1653 * dont do any more name translation on it. 1650 * dont do any more name translation on it.
1654 * 1651 *
1655 * Returns a pointer to the given map. 1652 * Returns a pointer to the given map.
1656 */ 1653 */
1657
1658maptile * 1654maptile *
1659ready_map_name (const char *name, int flags) 1655ready_map_name (const char *name, int flags)
1660{ 1656{
1661 maptile *m; 1657 maptile *m;
1662 1658

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines