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.3 by root, Sun Sep 10 16:06:37 2006 UTC vs.
Revision 1.21 by root, Mon Oct 12 14:00:58 2009 UTC

1
2/* 1/*
3 * static char *rcsid_standalone_c = 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
4 * "$Id: standalone.C,v 1.3 2006/09/10 16:06:37 root 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 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 *
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 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 *
22 * The authors can be reached via e-mail to <support@deliantra.net>
5 */ 23 */
6
7/*
8 CrossFire, A Multiplayer game for X-windows
9
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 The authors can be reached via e-mail at crossfire-devel@real-time.com
28*/
29 24
30#define LO_NEWFILE 2 25#define LO_NEWFILE 2
31 26
32/* the main routine for making a standalone version. */ 27/* the main routine for making a standalone version. */
33 28
41 36
42int 37int
43main (int argc, char *argv[]) 38main (int argc, char *argv[])
44{ 39{
45 char InFileName[1024], OutFileName[1024]; 40 char InFileName[1024], OutFileName[1024];
46 mapstruct *newMap; 41 maptile *newMap;
47 RMParms rp; 42 random_map_params rp;
48 FILE *fp; 43 FILE *fp;
49 44
50 if (argc < 3) 45 if (argc < 3)
51 { 46 {
52 printf ("\nUsage: %s inputfile outputfile\n", argv[0]); 47 printf ("\nUsage: %s inputfile outputfile\n", argv[0]);
53 exit (0); 48 exit (0);
54 } 49 }
50
55 strcpy (InFileName, argv[1]); 51 strcpy (InFileName, argv[1]);
56 strcpy (OutFileName, argv[2]); 52 strcpy (OutFileName, argv[2]);
57 53
58 init_globals (); 54 init_globals ();
59 init_library (); 55 init_library ();
61 init_artifacts (); 57 init_artifacts ();
62 init_formulae (); 58 init_formulae ();
63 init_readable (); 59 init_readable ();
64 60
65 init_gods (); 61 init_gods ();
66 memset (&rp, 0, sizeof (RMParms)); 62 memset (&rp, 0, sizeof (random_map_params));
67 rp.Xsize = -1; 63 rp.Xsize = -1;
68 rp.Ysize = -1; 64 rp.Ysize = -1;
69 if ((fp = fopen (InFileName, "r")) == NULL) 65 if ((fp = fopen (InFileName, "r")) == NULL)
70 { 66 {
71 fprintf (stderr, "\nError: can not open %s\n", InFileName); 67 fprintf (stderr, "\nError: can not open %s\n", InFileName);
77 new_save_map (newMap, 1); 73 new_save_map (newMap, 1);
78 exit (0); 74 exit (0);
79} 75}
80 76
81void 77void
82set_map_timeout (mapstruct *) 78set_map_timeout (maptile *)
83{ 79{
84} /* doesn't need to do anything */ 80} /* doesn't need to do anything */
85 81
86#include <global.h> 82#include <global.h>
87
88 83
89/* some plagarized code from apply.c--I needed just these two functions 84/* some plagarized code from apply.c--I needed just these two functions
90without all the rest of the junk, so.... */ 85without all the rest of the junk, so.... */
91int 86int
92auto_apply (object *op) 87auto_apply (object *op)
94 object *tmp = NULL; 89 object *tmp = NULL;
95 int i; 90 int i;
96 91
97 switch (op->type) 92 switch (op->type)
98 { 93 {
99 case SHOP_FLOOR: 94 case SHOP_FLOOR:
100 if (!HAS_RANDOM_ITEMS (op)) 95 if (!op->has_random_items ())
101 return 0; 96 return 0;
102 do 97 do
103 { 98 {
104 i = 10; /* let's give it 10 tries */ 99 i = 10; /* let's give it 10 tries */
100
105 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i); 101 while (!(tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5))
102 && --i)
103 ;
104
106 if (tmp == NULL) 105 if (tmp == NULL)
107 return 0; 106 return 0;
107
108 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 108 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
109 { 109 {
110 free_object (tmp); 110 tmp->destroy ();
111 tmp = NULL; 111 tmp = NULL;
112 } 112 }
113 } 113 }
114 while (!tmp); 114 while (!tmp);
115 115
116 tmp->x = op->x, tmp->y = op->y; 116 tmp->x = op->x, tmp->y = op->y;
117 SET_FLAG (tmp, FLAG_UNPAID); 117 SET_FLAG (tmp, FLAG_UNPAID);
118 insert_ob_in_map (tmp, op->map, NULL, 0); 118 insert_ob_in_map (tmp, op->map, NULL, 0);
119 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 119 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
120 identify (tmp); 120 identify (tmp);
121 break; 121 break;
122 122
123 case TREASURE: 123 case TREASURE:
124 if (HAS_RANDOM_ITEMS (op)) 124 if (op->has_random_items ())
125 while ((op->stats.hp--) > 0) 125 while ((op->stats.hp--) > 0)
126 create_treasure (op->randomitems, op, GT_ENVIRONMENT, 126 create_treasure (op->randomitems, op, GT_ENVIRONMENT,
127 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); 127 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
128 remove_ob (op); 128
129 free_object (op); 129 op->destroy ();
130 break; 130 break;
131 } 131 }
132 132
133 return tmp ? 1 : 0; 133 return tmp ? 1 : 0;
134} 134}
135 135
136/* 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
137 * when an original map is loaded) and performs special actions for 137 * when an original map is loaded) and performs special actions for
138 * certain objects (most initialization of chests and creation of 138 * certain objects (most initialization of chests and creation of
139 * treasures and stuff). Calls auto_apply if appropriate. 139 * treasures and stuff). Calls auto_apply if appropriate.
140 */ 140 */
141
142void 141void
143fix_auto_apply (mapstruct *m) 142fix_auto_apply (maptile *m)
144{ 143{
145 object *tmp, *above = NULL; 144 object *tmp, *above = NULL;
146 int x, y; 145 int x, y;
147 146
148 for (x = 0; x < MAP_WIDTH (m); x++) 147 for (x = 0; x < m->width; x++)
149 for (y = 0; y < MAP_HEIGHT (m); y++) 148 for (y = 0; y < m->height; y++)
150 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 149 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
151 { 150 {
152 above = tmp->above; 151 above = tmp->above;
153 152
154 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) 153 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
155 auto_apply (tmp); 154 auto_apply (tmp);
156 else if (tmp->type == TREASURE) 155 else if (tmp->type == TREASURE)
157 { 156 {
158 if (HAS_RANDOM_ITEMS (tmp)) 157 if (tmp->has_random_items ())
159 while ((tmp->stats.hp--) > 0) 158 while ((tmp->stats.hp--) > 0)
160 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 159 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
161 } 160 }
162 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems) 161 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems)
163 { 162 {
164 if (tmp->type == CONTAINER) 163 if (tmp->type == CONTAINER)
165 { 164 {
166 if (HAS_RANDOM_ITEMS (tmp)) 165 if (tmp->has_random_items ())
167 while ((tmp->stats.hp--) > 0) 166 while ((tmp->stats.hp--) > 0)
168 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 167 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
169 } 168 }
170 else if (HAS_RANDOM_ITEMS (tmp)) 169 else if (tmp->has_random_items ())
171 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 170 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
172 } 171 }
173 } 172 }
174 for (x = 0; x < MAP_WIDTH (m); x++) 173 for (x = 0; x < m->width; x++)
175 for (y = 0; y < MAP_HEIGHT (m); y++) 174 for (y = 0; y < m->height; y++)
176 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 175 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
177 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL)) 176 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
178 check_trigger (tmp, tmp->above); 177 check_trigger (tmp, tmp->above, tmp->above);
179} 178}
180 179
181/** 180/**
182 * Those are dummy functions defined to resolve all symboles. 181 * Those are dummy functions defined to resolve all symboles.
183 * Added as part of glue cleaning. 182 * Added as part of glue cleaning.
189{ 188{
190 fprintf (logfile, "%s\n", txt); 189 fprintf (logfile, "%s\n", txt);
191} 190}
192 191
193void 192void
194new_info_map (int color, mapstruct *map, const char *str) 193new_info_map (int color, maptile *map, const char *str)
195{ 194{
196 fprintf (logfile, "new_info_map: %s\n", str); 195 fprintf (logfile, "new_info_map: %s\n", str);
197} 196}
198 197
199void 198void
245weather_effect (const char *c) 244weather_effect (const char *c)
246{ 245{
247} 246}
248 247
249void 248void
250set_darkness_map (mapstruct *m) 249set_darkness_map (maptile *m)
251{ 250{
252} 251}
253 252
254void 253void
255move_apply (object *ob, object *obt, object *obx) 254move_apply (object *ob, object *obt, object *obx)
279 278
280void 279void
281trap_adjust (object *ob, int x) 280trap_adjust (object *ob, int x)
282{ 281{
283} 282}
283

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines