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.13 by pippijn, Sat Jan 6 14:42:30 2007 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
5 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 6 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 7 Copyright (C) 1992 Frank Tore Johansen
12 8
13 This program is free software; you can redistribute it and/or modify 9 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 10 it under the terms of the GNU General Public License as published by
22 18
23 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 20 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 22
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 23 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 24*/
29 25
30#define LO_NEWFILE 2 26#define LO_NEWFILE 2
31 27
32/* the main routine for making a standalone version. */ 28/* the main routine for making a standalone version. */
41 37
42int 38int
43main (int argc, char *argv[]) 39main (int argc, char *argv[])
44{ 40{
45 char InFileName[1024], OutFileName[1024]; 41 char InFileName[1024], OutFileName[1024];
46 mapstruct *newMap; 42 maptile *newMap;
47 RMParms rp; 43 random_map_params rp;
48 FILE *fp; 44 FILE *fp;
49 45
50 if (argc < 3) 46 if (argc < 3)
51 { 47 {
52 printf ("\nUsage: %s inputfile outputfile\n", argv[0]); 48 printf ("\nUsage: %s inputfile outputfile\n", argv[0]);
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 83
94 object *tmp = NULL; 90 object *tmp = NULL;
95 int i; 91 int i;
96 92
97 switch (op->type) 93 switch (op->type)
98 { 94 {
99 case SHOP_FLOOR: 95 case SHOP_FLOOR:
100 if (!HAS_RANDOM_ITEMS (op)) 96 if (!op->has_random_items ())
101 return 0; 97 return 0;
102 do 98 do
103 { 99 {
104 i = 10; /* let's give it 10 tries */ 100 i = 10; /* let's give it 10 tries */
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)) == NULL && --i);
106 if (tmp == NULL) 102 if (tmp == NULL)
107 return 0; 103 return 0;
108 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 104 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
109 { 105 {
110 free_object (tmp); 106 tmp->destroy ();
111 tmp = NULL; 107 tmp = NULL;
112 } 108 }
113 } 109 }
114 while (!tmp); 110 while (!tmp);
115 111
116 tmp->x = op->x, tmp->y = op->y; 112 tmp->x = op->x, tmp->y = op->y;
117 SET_FLAG (tmp, FLAG_UNPAID); 113 SET_FLAG (tmp, FLAG_UNPAID);
118 insert_ob_in_map (tmp, op->map, NULL, 0); 114 insert_ob_in_map (tmp, op->map, NULL, 0);
119 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 115 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
120 identify (tmp); 116 identify (tmp);
121 break; 117 break;
122 118
123 case TREASURE: 119 case TREASURE:
124 if (HAS_RANDOM_ITEMS (op)) 120 if (op->has_random_items ())
125 while ((op->stats.hp--) > 0) 121 while ((op->stats.hp--) > 0)
126 create_treasure (op->randomitems, op, GT_ENVIRONMENT, 122 create_treasure (op->randomitems, op, GT_ENVIRONMENT,
127 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); 123 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
128 remove_ob (op); 124 op->remove ();
129 free_object (op); 125 op->destroy ();
130 break; 126 break;
131 } 127 }
132 128
133 return tmp ? 1 : 0; 129 return tmp ? 1 : 0;
134} 130}
135 131
138 * certain objects (most initialization of chests and creation of 134 * certain objects (most initialization of chests and creation of
139 * treasures and stuff). Calls auto_apply if appropriate. 135 * treasures and stuff). Calls auto_apply if appropriate.
140 */ 136 */
141 137
142void 138void
143fix_auto_apply (mapstruct *m) 139fix_auto_apply (maptile *m)
144{ 140{
145 object *tmp, *above = NULL; 141 object *tmp, *above = NULL;
146 int x, y; 142 int x, y;
147 143
148 for (x = 0; x < MAP_WIDTH (m); x++) 144 for (x = 0; x < m->width; x++)
149 for (y = 0; y < MAP_HEIGHT (m); y++) 145 for (y = 0; y < m->height; y++)
150 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 146 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
151 { 147 {
152 above = tmp->above; 148 above = tmp->above;
153 149
154 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) 150 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
155 auto_apply (tmp); 151 auto_apply (tmp);
156 else if (tmp->type == TREASURE) 152 else if (tmp->type == TREASURE)
157 { 153 {
158 if (HAS_RANDOM_ITEMS (tmp)) 154 if (tmp->has_random_items ())
159 while ((tmp->stats.hp--) > 0) 155 while ((tmp->stats.hp--) > 0)
160 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 156 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
161 } 157 }
162 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems) 158 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems)
163 { 159 {
164 if (tmp->type == CONTAINER) 160 if (tmp->type == CONTAINER)
165 { 161 {
166 if (HAS_RANDOM_ITEMS (tmp)) 162 if (tmp->has_random_items ())
167 while ((tmp->stats.hp--) > 0) 163 while ((tmp->stats.hp--) > 0)
168 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 164 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
169 } 165 }
170 else if (HAS_RANDOM_ITEMS (tmp)) 166 else if (tmp->has_random_items ())
171 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 167 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
172 } 168 }
173 } 169 }
174 for (x = 0; x < MAP_WIDTH (m); x++) 170 for (x = 0; x < m->width; x++)
175 for (y = 0; y < MAP_HEIGHT (m); y++) 171 for (y = 0; y < m->height; y++)
176 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 172 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)) 173 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
178 check_trigger (tmp, tmp->above); 174 check_trigger (tmp, tmp->above);
179} 175}
180 176
181/** 177/**
189{ 185{
190 fprintf (logfile, "%s\n", txt); 186 fprintf (logfile, "%s\n", txt);
191} 187}
192 188
193void 189void
194new_info_map (int color, mapstruct *map, const char *str) 190new_info_map (int color, maptile *map, const char *str)
195{ 191{
196 fprintf (logfile, "new_info_map: %s\n", str); 192 fprintf (logfile, "new_info_map: %s\n", str);
197} 193}
198 194
199void 195void
245weather_effect (const char *c) 241weather_effect (const char *c)
246{ 242{
247} 243}
248 244
249void 245void
250set_darkness_map (mapstruct *m) 246set_darkness_map (maptile *m)
251{ 247{
252} 248}
253 249
254void 250void
255move_apply (object *ob, object *obt, object *obx) 251move_apply (object *ob, object *obt, object *obx)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines