1 |
|
2 |
/* |
3 |
CrossFire, A Multiplayer game for X-windows |
4 |
|
5 |
Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
6 |
Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
7 |
Copyright (C) 1992 Frank Tore Johansen |
8 |
|
9 |
This program is free software; you can redistribute it and/or modify |
10 |
it under the terms of the GNU General Public License as published by |
11 |
the Free Software Foundation; either version 2 of the License, or |
12 |
(at your option) any later version. |
13 |
|
14 |
This program is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
GNU General Public License for more details. |
18 |
|
19 |
You should have received a copy of the GNU General Public License |
20 |
along with this program; if not, write to the Free Software |
21 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 |
|
23 |
The authors can be reached via e-mail at <crossfire@schmorp.de> |
24 |
*/ |
25 |
|
26 |
#define LO_NEWFILE 2 |
27 |
|
28 |
/* the main routine for making a standalone version. */ |
29 |
|
30 |
#include <time.h> |
31 |
#include <stdio.h> |
32 |
#include <global.h> |
33 |
#include <maze_gen.h> |
34 |
#include <room_gen.h> |
35 |
#include <random_map.h> |
36 |
#include <rproto.h> |
37 |
|
38 |
int |
39 |
main (int argc, char *argv[]) |
40 |
{ |
41 |
char InFileName[1024], OutFileName[1024]; |
42 |
maptile *newMap; |
43 |
random_map_params rp; |
44 |
FILE *fp; |
45 |
|
46 |
if (argc < 3) |
47 |
{ |
48 |
printf ("\nUsage: %s inputfile outputfile\n", argv[0]); |
49 |
exit (0); |
50 |
} |
51 |
strcpy (InFileName, argv[1]); |
52 |
strcpy (OutFileName, argv[2]); |
53 |
|
54 |
init_globals (); |
55 |
init_library (); |
56 |
init_archetypes (); |
57 |
init_artifacts (); |
58 |
init_formulae (); |
59 |
init_readable (); |
60 |
|
61 |
init_gods (); |
62 |
memset (&rp, 0, sizeof (random_map_params)); |
63 |
rp.Xsize = -1; |
64 |
rp.Ysize = -1; |
65 |
if ((fp = fopen (InFileName, "r")) == NULL) |
66 |
{ |
67 |
fprintf (stderr, "\nError: can not open %s\n", InFileName); |
68 |
exit (1); |
69 |
} |
70 |
load_parameters (fp, LO_NEWFILE, &rp); |
71 |
fclose (fp); |
72 |
newMap = generate_random_map (OutFileName, &rp); |
73 |
new_save_map (newMap, 1); |
74 |
exit (0); |
75 |
} |
76 |
|
77 |
void |
78 |
set_map_timeout (maptile *) |
79 |
{ |
80 |
} /* doesn't need to do anything */ |
81 |
|
82 |
#include <global.h> |
83 |
|
84 |
|
85 |
/* some plagarized code from apply.c--I needed just these two functions |
86 |
without all the rest of the junk, so.... */ |
87 |
int |
88 |
auto_apply (object *op) |
89 |
{ |
90 |
object *tmp = NULL; |
91 |
int i; |
92 |
|
93 |
switch (op->type) |
94 |
{ |
95 |
case SHOP_FLOOR: |
96 |
if (!op->has_random_items ()) |
97 |
return 0; |
98 |
do |
99 |
{ |
100 |
i = 10; /* let's give it 10 tries */ |
101 |
while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i); |
102 |
if (tmp == NULL) |
103 |
return 0; |
104 |
if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
105 |
{ |
106 |
tmp->destroy (); |
107 |
tmp = NULL; |
108 |
} |
109 |
} |
110 |
while (!tmp); |
111 |
|
112 |
tmp->x = op->x, tmp->y = op->y; |
113 |
SET_FLAG (tmp, FLAG_UNPAID); |
114 |
insert_ob_in_map (tmp, op->map, NULL, 0); |
115 |
CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
116 |
identify (tmp); |
117 |
break; |
118 |
|
119 |
case TREASURE: |
120 |
if (op->has_random_items ()) |
121 |
while ((op->stats.hp--) > 0) |
122 |
create_treasure (op->randomitems, op, GT_ENVIRONMENT, |
123 |
op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
124 |
op->remove (); |
125 |
op->destroy (); |
126 |
break; |
127 |
} |
128 |
|
129 |
return tmp ? 1 : 0; |
130 |
} |
131 |
|
132 |
/* fix_auto_apply goes through the entire map (only the first time |
133 |
* when an original map is loaded) and performs special actions for |
134 |
* certain objects (most initialization of chests and creation of |
135 |
* treasures and stuff). Calls auto_apply if appropriate. |
136 |
*/ |
137 |
|
138 |
void |
139 |
fix_auto_apply (maptile *m) |
140 |
{ |
141 |
object *tmp, *above = NULL; |
142 |
int x, y; |
143 |
|
144 |
for (x = 0; x < m->width; x++) |
145 |
for (y = 0; y < m->height; y++) |
146 |
for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above) |
147 |
{ |
148 |
above = tmp->above; |
149 |
|
150 |
if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
151 |
auto_apply (tmp); |
152 |
else if (tmp->type == TREASURE) |
153 |
{ |
154 |
if (tmp->has_random_items ()) |
155 |
while ((tmp->stats.hp--) > 0) |
156 |
create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
157 |
} |
158 |
if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems) |
159 |
{ |
160 |
if (tmp->type == CONTAINER) |
161 |
{ |
162 |
if (tmp->has_random_items ()) |
163 |
while ((tmp->stats.hp--) > 0) |
164 |
create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
165 |
} |
166 |
else if (tmp->has_random_items ()) |
167 |
create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
168 |
} |
169 |
} |
170 |
for (x = 0; x < m->width; x++) |
171 |
for (y = 0; y < m->height; y++) |
172 |
for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
173 |
if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
174 |
check_trigger (tmp, tmp->above); |
175 |
} |
176 |
|
177 |
/** |
178 |
* Those are dummy functions defined to resolve all symboles. |
179 |
* Added as part of glue cleaning. |
180 |
* Ryo 2005-07-15 |
181 |
**/ |
182 |
|
183 |
void |
184 |
new_draw_info (int a, int b, const object *ob, const char *txt) |
185 |
{ |
186 |
fprintf (logfile, "%s\n", txt); |
187 |
} |
188 |
|
189 |
void |
190 |
new_info_map (int color, maptile *map, const char *str) |
191 |
{ |
192 |
fprintf (logfile, "new_info_map: %s\n", str); |
193 |
} |
194 |
|
195 |
void |
196 |
move_teleporter (object *ob) |
197 |
{ |
198 |
} |
199 |
|
200 |
void |
201 |
move_firewall (object *ob) |
202 |
{ |
203 |
} |
204 |
|
205 |
void |
206 |
move_duplicator (object *ob) |
207 |
{ |
208 |
} |
209 |
|
210 |
void |
211 |
move_marker (object *ob) |
212 |
{ |
213 |
} |
214 |
|
215 |
void |
216 |
move_creator (object *ob) |
217 |
{ |
218 |
} |
219 |
|
220 |
void |
221 |
emergency_save (int x) |
222 |
{ |
223 |
} |
224 |
|
225 |
void |
226 |
clean_tmp_files (void) |
227 |
{ |
228 |
} |
229 |
|
230 |
void |
231 |
esrv_send_item (object *ob, object *obx) |
232 |
{ |
233 |
} |
234 |
|
235 |
void |
236 |
dragon_ability_gain (object *ob, int x, int y) |
237 |
{ |
238 |
} |
239 |
|
240 |
void |
241 |
weather_effect (const char *c) |
242 |
{ |
243 |
} |
244 |
|
245 |
void |
246 |
set_darkness_map (maptile *m) |
247 |
{ |
248 |
} |
249 |
|
250 |
void |
251 |
move_apply (object *ob, object *obt, object *obx) |
252 |
{ |
253 |
} |
254 |
|
255 |
object * |
256 |
find_skill_by_number (object *ob, int x) |
257 |
{ |
258 |
return NULL; |
259 |
} |
260 |
|
261 |
void |
262 |
esrv_del_item (player *pl, int tag) |
263 |
{ |
264 |
} |
265 |
|
266 |
void |
267 |
esrv_update_spells (player *pl) |
268 |
{ |
269 |
} |
270 |
|
271 |
void |
272 |
monster_check_apply (object *ob, object *obt) |
273 |
{ |
274 |
} |
275 |
|
276 |
void |
277 |
trap_adjust (object *ob, int x) |
278 |
{ |
279 |
} |