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

Comparing deliantra/server/random_maps/standalone.C (file contents):
Revision 1.7 by root, Tue Dec 12 21:39:56 2006 UTC vs.
Revision 1.12 by root, Sun Dec 31 19:02:24 2006 UTC

1
1/* 2/*
2 CrossFire, A Multiplayer game for X-windows 3 CrossFire, A Multiplayer game for X-windows
3 4
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
36int 37int
37main (int argc, char *argv[]) 38main (int argc, char *argv[])
38{ 39{
39 char InFileName[1024], OutFileName[1024]; 40 char InFileName[1024], OutFileName[1024];
40 maptile *newMap; 41 maptile *newMap;
41 RMParms rp; 42 random_map_params rp;
42 FILE *fp; 43 FILE *fp;
43 44
44 if (argc < 3) 45 if (argc < 3)
45 { 46 {
46 printf ("\nUsage: %s inputfile outputfile\n", argv[0]); 47 printf ("\nUsage: %s inputfile outputfile\n", argv[0]);
55 init_artifacts (); 56 init_artifacts ();
56 init_formulae (); 57 init_formulae ();
57 init_readable (); 58 init_readable ();
58 59
59 init_gods (); 60 init_gods ();
60 memset (&rp, 0, sizeof (RMParms)); 61 memset (&rp, 0, sizeof (random_map_params));
61 rp.Xsize = -1; 62 rp.Xsize = -1;
62 rp.Ysize = -1; 63 rp.Ysize = -1;
63 if ((fp = fopen (InFileName, "r")) == NULL) 64 if ((fp = fopen (InFileName, "r")) == NULL)
64 { 65 {
65 fprintf (stderr, "\nError: can not open %s\n", InFileName); 66 fprintf (stderr, "\nError: can not open %s\n", InFileName);
88 object *tmp = NULL; 89 object *tmp = NULL;
89 int i; 90 int i;
90 91
91 switch (op->type) 92 switch (op->type)
92 { 93 {
93 case SHOP_FLOOR: 94 case SHOP_FLOOR:
94 if (!HAS_RANDOM_ITEMS (op)) 95 if (!op->has_random_items ())
95 return 0; 96 return 0;
96 do 97 do
97 { 98 {
98 i = 10; /* let's give it 10 tries */ 99 i = 10; /* let's give it 10 tries */
99 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i); 100 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i);
100 if (tmp == NULL) 101 if (tmp == NULL)
101 return 0; 102 return 0;
102 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 103 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
103 { 104 {
104 tmp->destroy (); 105 tmp->destroy ();
105 tmp = NULL; 106 tmp = NULL;
106 } 107 }
107 } 108 }
108 while (!tmp); 109 while (!tmp);
109 110
110 tmp->x = op->x, tmp->y = op->y; 111 tmp->x = op->x, tmp->y = op->y;
111 SET_FLAG (tmp, FLAG_UNPAID); 112 SET_FLAG (tmp, FLAG_UNPAID);
112 insert_ob_in_map (tmp, op->map, NULL, 0); 113 insert_ob_in_map (tmp, op->map, NULL, 0);
113 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 114 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
114 identify (tmp); 115 identify (tmp);
115 break; 116 break;
116 117
117 case TREASURE: 118 case TREASURE:
118 if (HAS_RANDOM_ITEMS (op)) 119 if (op->has_random_items ())
119 while ((op->stats.hp--) > 0) 120 while ((op->stats.hp--) > 0)
120 create_treasure (op->randomitems, op, GT_ENVIRONMENT, 121 create_treasure (op->randomitems, op, GT_ENVIRONMENT,
121 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); 122 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
122 op->remove (); 123 op->remove ();
123 op->destroy (); 124 op->destroy ();
124 break; 125 break;
125 } 126 }
126 127
127 return tmp ? 1 : 0; 128 return tmp ? 1 : 0;
128} 129}
129 130
137fix_auto_apply (maptile *m) 138fix_auto_apply (maptile *m)
138{ 139{
139 object *tmp, *above = NULL; 140 object *tmp, *above = NULL;
140 int x, y; 141 int x, y;
141 142
142 for (x = 0; x < MAP_WIDTH (m); x++) 143 for (x = 0; x < m->width; x++)
143 for (y = 0; y < MAP_HEIGHT (m); y++) 144 for (y = 0; y < m->height; y++)
144 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 145 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
145 { 146 {
146 above = tmp->above; 147 above = tmp->above;
147 148
148 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) 149 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
149 auto_apply (tmp); 150 auto_apply (tmp);
150 else if (tmp->type == TREASURE) 151 else if (tmp->type == TREASURE)
151 { 152 {
152 if (HAS_RANDOM_ITEMS (tmp)) 153 if (tmp->has_random_items ())
153 while ((tmp->stats.hp--) > 0) 154 while ((tmp->stats.hp--) > 0)
154 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 155 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
155 } 156 }
156 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems) 157 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems)
157 { 158 {
158 if (tmp->type == CONTAINER) 159 if (tmp->type == CONTAINER)
159 { 160 {
160 if (HAS_RANDOM_ITEMS (tmp)) 161 if (tmp->has_random_items ())
161 while ((tmp->stats.hp--) > 0) 162 while ((tmp->stats.hp--) > 0)
162 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 163 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
163 } 164 }
164 else if (HAS_RANDOM_ITEMS (tmp)) 165 else if (tmp->has_random_items ())
165 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 166 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
166 } 167 }
167 } 168 }
168 for (x = 0; x < MAP_WIDTH (m); x++) 169 for (x = 0; x < m->width; x++)
169 for (y = 0; y < MAP_HEIGHT (m); y++) 170 for (y = 0; y < m->height; y++)
170 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 171 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
171 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) 172 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
172 check_trigger (tmp, tmp->above); 173 check_trigger (tmp, tmp->above);
173} 174}
174 175
175/** 176/**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines