ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/standalone.C
(Generate patch)

Comparing deliantra/server/random_maps/standalone.C (file contents):
Revision 1.2 by root, Tue Aug 29 08:01:36 2006 UTC vs.
Revision 1.3 by root, Sun Sep 10 16:06:37 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines