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.16 by root, Thu Nov 8 19:43:25 2007 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 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>
5 */ 22 */
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 23
30#define LO_NEWFILE 2 24#define LO_NEWFILE 2
31 25
32/* the main routine for making a standalone version. */ 26/* the main routine for making a standalone version. */
33 27
41 35
42int 36int
43main (int argc, char *argv[]) 37main (int argc, char *argv[])
44{ 38{
45 char InFileName[1024], OutFileName[1024]; 39 char InFileName[1024], OutFileName[1024];
46 mapstruct *newMap; 40 maptile *newMap;
47 RMParms rp; 41 random_map_params rp;
48 FILE *fp; 42 FILE *fp;
49 43
50 if (argc < 3) 44 if (argc < 3)
51 { 45 {
52 printf ("\nUsage: %s inputfile outputfile\n", argv[0]); 46 printf ("\nUsage: %s inputfile outputfile\n", argv[0]);
61 init_artifacts (); 55 init_artifacts ();
62 init_formulae (); 56 init_formulae ();
63 init_readable (); 57 init_readable ();
64 58
65 init_gods (); 59 init_gods ();
66 memset (&rp, 0, sizeof (RMParms)); 60 memset (&rp, 0, sizeof (random_map_params));
67 rp.Xsize = -1; 61 rp.Xsize = -1;
68 rp.Ysize = -1; 62 rp.Ysize = -1;
69 if ((fp = fopen (InFileName, "r")) == NULL) 63 if ((fp = fopen (InFileName, "r")) == NULL)
70 { 64 {
71 fprintf (stderr, "\nError: can not open %s\n", InFileName); 65 fprintf (stderr, "\nError: can not open %s\n", InFileName);
77 new_save_map (newMap, 1); 71 new_save_map (newMap, 1);
78 exit (0); 72 exit (0);
79} 73}
80 74
81void 75void
82set_map_timeout (mapstruct *) 76set_map_timeout (maptile *)
83{ 77{
84} /* doesn't need to do anything */ 78} /* doesn't need to do anything */
85 79
86#include <global.h> 80#include <global.h>
87 81
94 object *tmp = NULL; 88 object *tmp = NULL;
95 int i; 89 int i;
96 90
97 switch (op->type) 91 switch (op->type)
98 { 92 {
99 case SHOP_FLOOR: 93 case SHOP_FLOOR:
100 if (!HAS_RANDOM_ITEMS (op)) 94 if (!op->has_random_items ())
101 return 0; 95 return 0;
102 do 96 do
103 { 97 {
104 i = 10; /* let's give it 10 tries */ 98 i = 10; /* let's give it 10 tries */
105 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i); 99 while ((tmp = generate_treasure (op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i);
106 if (tmp == NULL) 100 if (tmp == NULL)
107 return 0; 101 return 0;
108 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 102 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
109 { 103 {
110 free_object (tmp); 104 tmp->destroy ();
111 tmp = NULL; 105 tmp = NULL;
112 } 106 }
113 } 107 }
114 while (!tmp); 108 while (!tmp);
115 109
116 tmp->x = op->x, tmp->y = op->y; 110 tmp->x = op->x, tmp->y = op->y;
117 SET_FLAG (tmp, FLAG_UNPAID); 111 SET_FLAG (tmp, FLAG_UNPAID);
118 insert_ob_in_map (tmp, op->map, NULL, 0); 112 insert_ob_in_map (tmp, op->map, NULL, 0);
119 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 113 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
120 identify (tmp); 114 identify (tmp);
121 break; 115 break;
122 116
123 case TREASURE: 117 case TREASURE:
124 if (HAS_RANDOM_ITEMS (op)) 118 if (op->has_random_items ())
125 while ((op->stats.hp--) > 0) 119 while ((op->stats.hp--) > 0)
126 create_treasure (op->randomitems, op, GT_ENVIRONMENT, 120 create_treasure (op->randomitems, op, GT_ENVIRONMENT,
127 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); 121 op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
128 remove_ob (op); 122 op->remove ();
129 free_object (op); 123 op->destroy ();
130 break; 124 break;
131 } 125 }
132 126
133 return tmp ? 1 : 0; 127 return tmp ? 1 : 0;
134} 128}
135 129
138 * certain objects (most initialization of chests and creation of 132 * certain objects (most initialization of chests and creation of
139 * treasures and stuff). Calls auto_apply if appropriate. 133 * treasures and stuff). Calls auto_apply if appropriate.
140 */ 134 */
141 135
142void 136void
143fix_auto_apply (mapstruct *m) 137fix_auto_apply (maptile *m)
144{ 138{
145 object *tmp, *above = NULL; 139 object *tmp, *above = NULL;
146 int x, y; 140 int x, y;
147 141
148 for (x = 0; x < MAP_WIDTH (m); x++) 142 for (x = 0; x < m->width; x++)
149 for (y = 0; y < MAP_HEIGHT (m); y++) 143 for (y = 0; y < m->height; y++)
150 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) 144 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above)
151 { 145 {
152 above = tmp->above; 146 above = tmp->above;
153 147
154 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) 148 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY))
155 auto_apply (tmp); 149 auto_apply (tmp);
156 else if (tmp->type == TREASURE) 150 else if (tmp->type == TREASURE)
157 { 151 {
158 if (HAS_RANDOM_ITEMS (tmp)) 152 if (tmp->has_random_items ())
159 while ((tmp->stats.hp--) > 0) 153 while ((tmp->stats.hp--) > 0)
160 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 154 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
161 } 155 }
162 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems) 156 if (tmp && tmp->arch && tmp->type != PLAYER && tmp->type != TREASURE && tmp->randomitems)
163 { 157 {
164 if (tmp->type == CONTAINER) 158 if (tmp->type == CONTAINER)
165 { 159 {
166 if (HAS_RANDOM_ITEMS (tmp)) 160 if (tmp->has_random_items ())
167 while ((tmp->stats.hp--) > 0) 161 while ((tmp->stats.hp--) > 0)
168 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0); 162 create_treasure (tmp->randomitems, tmp, 0, m->difficulty, 0);
169 } 163 }
170 else if (HAS_RANDOM_ITEMS (tmp)) 164 else if (tmp->has_random_items ())
171 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0); 165 create_treasure (tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
172 } 166 }
173 } 167 }
174 for (x = 0; x < MAP_WIDTH (m); x++) 168 for (x = 0; x < m->width; x++)
175 for (y = 0; y < MAP_HEIGHT (m); y++) 169 for (y = 0; y < m->height; y++)
176 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 170 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)) 171 if (tmp->above && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
178 check_trigger (tmp, tmp->above); 172 check_trigger (tmp, tmp->above);
179} 173}
180 174
181/** 175/**
189{ 183{
190 fprintf (logfile, "%s\n", txt); 184 fprintf (logfile, "%s\n", txt);
191} 185}
192 186
193void 187void
194new_info_map (int color, mapstruct *map, const char *str) 188new_info_map (int color, maptile *map, const char *str)
195{ 189{
196 fprintf (logfile, "new_info_map: %s\n", str); 190 fprintf (logfile, "new_info_map: %s\n", str);
197} 191}
198 192
199void 193void
245weather_effect (const char *c) 239weather_effect (const char *c)
246{ 240{
247} 241}
248 242
249void 243void
250set_darkness_map (mapstruct *m) 244set_darkness_map (maptile *m)
251{ 245{
252} 246}
253 247
254void 248void
255move_apply (object *ob, object *obt, object *obx) 249move_apply (object *ob, object *obt, object *obx)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines