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.1 by elmex, Sun Aug 13 17:16:03 2006 UTC vs.
Revision 1.18 by root, Mon Sep 29 09:04:51 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines