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.12 by root, Sun Dec 31 19:02:24 2006 UTC

1
2/*
3 * static char *rcsid_standalone_c =
4 * "$Id: standalone.C,v 1.3 2006/09/10 16:06:37 root Exp $";
5 */
6 1
7/* 2/*
8 CrossFire, A Multiplayer game for X-windows 3 CrossFire, A Multiplayer game for X-windows
9 4
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
22 17
23 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 21
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 22 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 23*/
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. */
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]);
61 init_artifacts (); 56 init_artifacts ();
62 init_formulae (); 57 init_formulae ();
63 init_readable (); 58 init_readable ();
64 59
65 init_gods (); 60 init_gods ();
66 memset (&rp, 0, sizeof (RMParms)); 61 memset (&rp, 0, sizeof (random_map_params));
67 rp.Xsize = -1; 62 rp.Xsize = -1;
68 rp.Ysize = -1; 63 rp.Ysize = -1;
69 if ((fp = fopen (InFileName, "r")) == NULL) 64 if ((fp = fopen (InFileName, "r")) == NULL)
70 { 65 {
71 fprintf (stderr, "\nError: can not open %s\n", InFileName); 66 fprintf (stderr, "\nError: can not open %s\n", InFileName);
77 new_save_map (newMap, 1); 72 new_save_map (newMap, 1);
78 exit (0); 73 exit (0);
79} 74}
80 75
81void 76void
82set_map_timeout (mapstruct *) 77set_map_timeout (maptile *)
83{ 78{
84} /* doesn't need to do anything */ 79} /* doesn't need to do anything */
85 80
86#include <global.h> 81#include <global.h>
87 82
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 */
105 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i); 100 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i);
106 if (tmp == NULL) 101 if (tmp == NULL)
107 return 0; 102 return 0;
108 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 103 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
109 { 104 {
110 free_object (tmp); 105 tmp->destroy ();
111 tmp = NULL; 106 tmp = NULL;
112 } 107 }
113 } 108 }
114 while (!tmp); 109 while (!tmp);
115 110
116 tmp->x = op->x, tmp->y = op->y; 111 tmp->x = op->x, tmp->y = op->y;
117 SET_FLAG (tmp, FLAG_UNPAID); 112 SET_FLAG (tmp, FLAG_UNPAID);
118 insert_ob_in_map (tmp, op->map, NULL, 0); 113 insert_ob_in_map (tmp, op->map, NULL, 0);
119 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 114 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
120 identify (tmp); 115 identify (tmp);
121 break; 116 break;
122 117
123 case TREASURE: 118 case TREASURE:
124 if (HAS_RANDOM_ITEMS (op)) 119 if (op->has_random_items ())
125 while ((op->stats.hp--) > 0) 120 while ((op->stats.hp--) > 0)
126 create_treasure (op->randomitems, op, GT_ENVIRONMENT, 121 create_treasure (op->randomitems, op, GT_ENVIRONMENT,
127 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); 122 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
128 remove_ob (op); 123 op->remove ();
129 free_object (op); 124 op->destroy ();
130 break; 125 break;
131 } 126 }
132 127
133 return tmp ? 1 : 0; 128 return tmp ? 1 : 0;
134} 129}
135 130
138 * certain objects (most initialization of chests and creation of 133 * certain objects (most initialization of chests and creation of
139 * treasures and stuff). Calls auto_apply if appropriate. 134 * treasures and stuff). Calls auto_apply if appropriate.
140 */ 135 */
141 136
142void 137void
143fix_auto_apply (mapstruct *m) 138fix_auto_apply (maptile *m)
144{ 139{
145 object *tmp, *above = NULL; 140 object *tmp, *above = NULL;
146 int x, y; 141 int x, y;
147 142
148 for (x = 0; x < MAP_WIDTH (m); x++) 143 for (x = 0; x < m->width; x++)
149 for (y = 0; y < MAP_HEIGHT (m); y++) 144 for (y = 0; y < m->height; y++)
150 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 145 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
151 { 146 {
152 above = tmp->above; 147 above = tmp->above;
153 148
154 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) 149 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
155 auto_apply (tmp); 150 auto_apply (tmp);
156 else if (tmp->type == TREASURE) 151 else if (tmp->type == TREASURE)
157 { 152 {
158 if (HAS_RANDOM_ITEMS (tmp)) 153 if (tmp->has_random_items ())
159 while ((tmp->stats.hp--) > 0) 154 while ((tmp->stats.hp--) > 0)
160 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 155 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
161 } 156 }
162 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems) 157 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems)
163 { 158 {
164 if (tmp->type == CONTAINER) 159 if (tmp->type == CONTAINER)
165 { 160 {
166 if (HAS_RANDOM_ITEMS (tmp)) 161 if (tmp->has_random_items ())
167 while ((tmp->stats.hp--) > 0) 162 while ((tmp->stats.hp--) > 0)
168 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 163 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
169 } 164 }
170 else if (HAS_RANDOM_ITEMS (tmp)) 165 else if (tmp->has_random_items ())
171 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 166 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
172 } 167 }
173 } 168 }
174 for (x = 0; x < MAP_WIDTH (m); x++) 169 for (x = 0; x < m->width; x++)
175 for (y = 0; y < MAP_HEIGHT (m); y++) 170 for (y = 0; y < m->height; y++)
176 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 171 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)) 172 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
178 check_trigger (tmp, tmp->above); 173 check_trigger (tmp, tmp->above);
179} 174}
180 175
181/** 176/**
189{ 184{
190 fprintf (logfile, "%s\n", txt); 185 fprintf (logfile, "%s\n", txt);
191} 186}
192 187
193void 188void
194new_info_map (int color, mapstruct *map, const char *str) 189new_info_map (int color, maptile *map, const char *str)
195{ 190{
196 fprintf (logfile, "new_info_map: %s\n", str); 191 fprintf (logfile, "new_info_map: %s\n", str);
197} 192}
198 193
199void 194void
245weather_effect (const char *c) 240weather_effect (const char *c)
246{ 241{
247} 242}
248 243
249void 244void
250set_darkness_map (mapstruct *m) 245set_darkness_map (maptile *m)
251{ 246{
252} 247}
253 248
254void 249void
255move_apply (object *ob, object *obt, object *obx) 250move_apply (object *ob, object *obt, object *obx)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines