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