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