1 |
elmex |
1.1 |
/* |
2 |
root |
1.16 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
pippijn |
1.14 |
* |
4 |
root |
1.17 |
* Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
root |
1.15 |
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 |
|
|
* Copyright (©) 1992,2007 Frank Tore Johansen |
7 |
pippijn |
1.14 |
* |
8 |
root |
1.21 |
* 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 |
pippijn |
1.14 |
* |
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 |
root |
1.15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
pippijn |
1.14 |
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
root |
1.21 |
* 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 |
root |
1.15 |
* |
22 |
root |
1.16 |
* The authors can be reached via e-mail to <support@deliantra.net> |
23 |
pippijn |
1.14 |
*/ |
24 |
elmex |
1.1 |
|
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 |
root |
1.3 |
int |
38 |
|
|
main (int argc, char *argv[]) |
39 |
|
|
{ |
40 |
|
|
char InFileName[1024], OutFileName[1024]; |
41 |
root |
1.5 |
maptile *newMap; |
42 |
root |
1.11 |
random_map_params rp; |
43 |
elmex |
1.1 |
FILE *fp; |
44 |
|
|
|
45 |
root |
1.3 |
if (argc < 3) |
46 |
|
|
{ |
47 |
|
|
printf ("\nUsage: %s inputfile outputfile\n", argv[0]); |
48 |
|
|
exit (0); |
49 |
|
|
} |
50 |
root |
1.17 |
|
51 |
root |
1.3 |
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 |
root |
1.11 |
memset (&rp, 0, sizeof (random_map_params)); |
63 |
root |
1.3 |
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 |
elmex |
1.1 |
} |
76 |
|
|
|
77 |
root |
1.3 |
void |
78 |
root |
1.5 |
set_map_timeout (maptile *) |
79 |
root |
1.3 |
{ |
80 |
|
|
} /* doesn't need to do anything */ |
81 |
elmex |
1.1 |
|
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 |
root |
1.3 |
int |
87 |
|
|
auto_apply (object *op) |
88 |
|
|
{ |
89 |
elmex |
1.1 |
object *tmp = NULL; |
90 |
|
|
int i; |
91 |
|
|
|
92 |
root |
1.3 |
switch (op->type) |
93 |
|
|
{ |
94 |
root |
1.12 |
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 |
root |
1.18 |
|
101 |
|
|
while (!(tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) |
102 |
|
|
&& --i) |
103 |
|
|
; |
104 |
|
|
|
105 |
root |
1.12 |
if (tmp == NULL) |
106 |
|
|
return 0; |
107 |
root |
1.18 |
|
108 |
root |
1.12 |
if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
109 |
|
|
{ |
110 |
root |
1.19 |
tmp->destroy (); |
111 |
root |
1.12 |
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 |
root |
1.18 |
|
129 |
root |
1.19 |
op->destroy (); |
130 |
root |
1.12 |
break; |
131 |
root |
1.3 |
} |
132 |
elmex |
1.1 |
|
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 |
root |
1.3 |
void |
142 |
root |
1.5 |
fix_auto_apply (maptile *m) |
143 |
root |
1.3 |
{ |
144 |
|
|
object *tmp, *above = NULL; |
145 |
|
|
int x, y; |
146 |
|
|
|
147 |
root |
1.10 |
for (x = 0; x < m->width; x++) |
148 |
|
|
for (y = 0; y < m->height; y++) |
149 |
root |
1.9 |
for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above) |
150 |
root |
1.3 |
{ |
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 |
root |
1.8 |
if (tmp->has_random_items ()) |
158 |
root |
1.3 |
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 |
root |
1.8 |
if (tmp->has_random_items ()) |
166 |
root |
1.3 |
while ((tmp->stats.hp--) > 0) |
167 |
|
|
create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); |
168 |
|
|
} |
169 |
root |
1.8 |
else if (tmp->has_random_items ()) |
170 |
root |
1.3 |
create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); |
171 |
|
|
} |
172 |
elmex |
1.1 |
} |
173 |
root |
1.10 |
for (x = 0; x < m->width; x++) |
174 |
|
|
for (y = 0; y < m->height; y++) |
175 |
root |
1.9 |
for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
176 |
root |
1.3 |
if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
177 |
root |
1.20 |
check_trigger (tmp, tmp->above, tmp->above); |
178 |
elmex |
1.1 |
} |
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 |
root |
1.3 |
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 |
root |
1.5 |
new_info_map (int color, maptile *map, const char *str) |
194 |
root |
1.3 |
{ |
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 |
root |
1.5 |
set_darkness_map (maptile *m) |
250 |
root |
1.3 |
{ |
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 |
root |
1.17 |
|