1 |
elmex |
1.1 |
/* |
2 |
|
|
* static char *rcsid_standalone_c = |
3 |
|
|
* "$Id$"; |
4 |
|
|
*/ |
5 |
|
|
|
6 |
|
|
/* |
7 |
|
|
CrossFire, A Multiplayer game for X-windows |
8 |
|
|
|
9 |
|
|
Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
10 |
|
|
Copyright (C) 1992 Frank Tore Johansen |
11 |
|
|
|
12 |
|
|
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 |
14 |
|
|
the Free Software Foundation; either version 2 of the License, or |
15 |
|
|
(at your option) any later version. |
16 |
|
|
|
17 |
|
|
This program is distributed in the hope that it will be useful, |
18 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 |
|
|
GNU General Public License for more details. |
21 |
|
|
|
22 |
|
|
You should have received a copy of the GNU General Public License |
23 |
|
|
along with this program; if not, write to the Free Software |
24 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 |
|
|
|
26 |
|
|
The authors can be reached via e-mail at crossfire-devel@real-time.com |
27 |
|
|
*/ |
28 |
|
|
|
29 |
|
|
#define LO_NEWFILE 2 |
30 |
|
|
|
31 |
|
|
/* the main routine for making a standalone version. */ |
32 |
|
|
|
33 |
|
|
#include <time.h> |
34 |
|
|
#include <stdio.h> |
35 |
|
|
#include <global.h> |
36 |
|
|
#include <maze_gen.h> |
37 |
|
|
#include <room_gen.h> |
38 |
|
|
#include <random_map.h> |
39 |
|
|
#include <rproto.h> |
40 |
|
|
|
41 |
|
|
int main(int argc, char *argv[]) { |
42 |
|
|
char InFileName[1024],OutFileName[1024]; |
43 |
|
|
mapstruct *newMap; |
44 |
|
|
RMParms rp; |
45 |
|
|
FILE *fp; |
46 |
|
|
|
47 |
|
|
if(argc < 3) { |
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(RMParms)); |
63 |
|
|
rp.Xsize=-1; |
64 |
|
|
rp.Ysize=-1; |
65 |
|
|
if ((fp=fopen(InFileName, "r"))==NULL) { |
66 |
|
|
fprintf(stderr,"\nError: can not open %s\n", InFileName); |
67 |
|
|
exit(1); |
68 |
|
|
} |
69 |
|
|
load_parameters(fp, LO_NEWFILE, &rp); |
70 |
|
|
fclose(fp); |
71 |
|
|
newMap = generate_random_map(OutFileName, &rp); |
72 |
|
|
new_save_map(newMap,1); |
73 |
|
|
exit(0); |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
void set_map_timeout(mapstruct *) {} /* doesn't need to do anything */ |
77 |
|
|
|
78 |
|
|
#include <global.h> |
79 |
|
|
|
80 |
|
|
|
81 |
|
|
/* some plagarized code from apply.c--I needed just these two functions |
82 |
|
|
without all the rest of the junk, so.... */ |
83 |
|
|
int auto_apply (object *op) { |
84 |
|
|
object *tmp = NULL; |
85 |
|
|
int i; |
86 |
|
|
|
87 |
|
|
switch(op->type) { |
88 |
|
|
case SHOP_FLOOR: |
89 |
|
|
if (!HAS_RANDOM_ITEMS(op)) return 0; |
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; |
96 |
|
|
if(QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) |
97 |
|
|
{ |
98 |
|
|
free_object(tmp); |
99 |
|
|
tmp = NULL; |
100 |
|
|
} |
101 |
|
|
} while(!tmp); |
102 |
|
|
|
103 |
|
|
tmp->x=op->x,tmp->y=op->y; |
104 |
|
|
SET_FLAG(tmp,FLAG_UNPAID); |
105 |
|
|
insert_ob_in_map(tmp,op->map,NULL,0); |
106 |
|
|
CLEAR_FLAG(op,FLAG_AUTO_APPLY); |
107 |
|
|
identify(tmp); |
108 |
|
|
break; |
109 |
|
|
|
110 |
|
|
case TREASURE: |
111 |
|
|
if (HAS_RANDOM_ITEMS(op)) |
112 |
|
|
while ((op->stats.hp--)>0) |
113 |
|
|
create_treasure(op->randomitems, op, GT_ENVIRONMENT, |
114 |
|
|
op->stats.exp ? op->stats.exp : |
115 |
|
|
op->map == NULL ? 14: op->map->difficulty,0); |
116 |
|
|
remove_ob(op); |
117 |
|
|
free_object(op); |
118 |
|
|
break; |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
return tmp ? 1 : 0; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
/* fix_auto_apply goes through the entire map (only the first time |
125 |
|
|
* when an original map is loaded) and performs special actions for |
126 |
|
|
* certain objects (most initialization of chests and creation of |
127 |
|
|
* treasures and stuff). Calls auto_apply if appropriate. |
128 |
|
|
*/ |
129 |
|
|
|
130 |
|
|
void fix_auto_apply(mapstruct *m) { |
131 |
|
|
object *tmp,*above=NULL; |
132 |
|
|
int x,y; |
133 |
|
|
|
134 |
|
|
for(x=0;x<MAP_WIDTH(m);x++) |
135 |
|
|
for(y=0;y<MAP_HEIGHT(m);y++) |
136 |
|
|
for(tmp=get_map_ob(m,x,y);tmp!=NULL;tmp=above) { |
137 |
|
|
above=tmp->above; |
138 |
|
|
|
139 |
|
|
if(QUERY_FLAG(tmp,FLAG_AUTO_APPLY)) |
140 |
|
|
auto_apply(tmp); |
141 |
|
|
else if(tmp->type==TREASURE) { |
142 |
|
|
if (HAS_RANDOM_ITEMS(tmp)) |
143 |
|
|
while ((tmp->stats.hp--)>0) |
144 |
|
|
create_treasure(tmp->randomitems, tmp, 0, |
145 |
|
|
m->difficulty,0); |
146 |
|
|
} |
147 |
|
|
if(tmp && tmp->arch && tmp->type!=PLAYER && tmp->type!=TREASURE && |
148 |
|
|
tmp->randomitems){ |
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) |
163 |
|
|
if (tmp->above |
164 |
|
|
&& (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) |
165 |
|
|
check_trigger(tmp,tmp->above); |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
/** |
169 |
|
|
* Those are dummy functions defined to resolve all symboles. |
170 |
|
|
* Added as part of glue cleaning. |
171 |
|
|
* Ryo 2005-07-15 |
172 |
|
|
**/ |
173 |
|
|
|
174 |
|
|
void new_draw_info(int a, int b, const object *ob, const char *txt) |
175 |
|
|
{ |
176 |
|
|
fprintf(logfile, "%s\n", txt); |
177 |
|
|
} |
178 |
|
|
void new_info_map(int color, mapstruct *map, const char *str) |
179 |
|
|
{ |
180 |
|
|
fprintf(logfile, "new_info_map: %s\n", str); |
181 |
|
|
} |
182 |
|
|
|
183 |
|
|
void move_teleporter( object* ob) |
184 |
|
|
{ |
185 |
|
|
} |
186 |
|
|
|
187 |
|
|
void move_firewall( object* ob) |
188 |
|
|
{ |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
void move_duplicator( object* ob) |
192 |
|
|
{ |
193 |
|
|
} |
194 |
|
|
|
195 |
|
|
void move_marker( object* ob) |
196 |
|
|
{ |
197 |
|
|
} |
198 |
|
|
|
199 |
|
|
void move_creator( object* ob) |
200 |
|
|
{ |
201 |
|
|
} |
202 |
|
|
|
203 |
|
|
void emergency_save( int x ) |
204 |
|
|
{ |
205 |
|
|
} |
206 |
|
|
|
207 |
|
|
void clean_tmp_files( void ) |
208 |
|
|
{ |
209 |
|
|
} |
210 |
|
|
|
211 |
|
|
void esrv_send_item( object* ob, object* obx ) |
212 |
|
|
{ |
213 |
|
|
} |
214 |
|
|
|
215 |
|
|
void dragon_ability_gain( object* ob, int x, int y ) |
216 |
|
|
{ |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
void weather_effect( const char* c ) |
220 |
|
|
{ |
221 |
|
|
} |
222 |
|
|
|
223 |
|
|
void set_darkness_map( mapstruct* m) |
224 |
|
|
{ |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
void move_apply( object* ob, object* obt, object* obx ) |
228 |
|
|
{ |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
object* find_skill_by_number( object* ob, int x ) |
232 |
|
|
{ |
233 |
|
|
return NULL; |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
void esrv_del_item(player *pl, int tag) |
237 |
|
|
{ |
238 |
|
|
} |
239 |
|
|
|
240 |
|
|
void esrv_update_spells(player *pl) |
241 |
|
|
{ |
242 |
|
|
} |
243 |
|
|
|
244 |
|
|
void monster_check_apply( object* ob, object* obt ) |
245 |
|
|
{ |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
void trap_adjust( object* ob, int x ) |
249 |
|
|
{ |
250 |
|
|
} |