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.10 by root, Mon Dec 25 14:43:23 2006 UTC vs.
Revision 1.13 by pippijn, Sat Jan 6 14:42:30 2007 UTC

1
1/* 2/*
2 CrossFire, A Multiplayer game for X-windows 3 CrossFire, A Multiplayer game for X-windows
3 4
5 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 6 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 7 Copyright (C) 1992 Frank Tore Johansen
6 8
7 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
8 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
36int 38int
37main (int argc, char *argv[]) 39main (int argc, char *argv[])
38{ 40{
39 char InFileName[1024], OutFileName[1024]; 41 char InFileName[1024], OutFileName[1024];
40 maptile *newMap; 42 maptile *newMap;
41 RMParms rp; 43 random_map_params rp;
42 FILE *fp; 44 FILE *fp;
43 45
44 if (argc < 3) 46 if (argc < 3)
45 { 47 {
46 printf ("\nUsage: %s inputfile outputfile\n", argv[0]); 48 printf ("\nUsage: %s inputfile outputfile\n", argv[0]);
55 init_artifacts (); 57 init_artifacts ();
56 init_formulae (); 58 init_formulae ();
57 init_readable (); 59 init_readable ();
58 60
59 init_gods (); 61 init_gods ();
60 memset (&rp, 0, sizeof (RMParms)); 62 memset (&rp, 0, sizeof (random_map_params));
61 rp.Xsize = -1; 63 rp.Xsize = -1;
62 rp.Ysize = -1; 64 rp.Ysize = -1;
63 if ((fp = fopen (InFileName, "r")) == NULL) 65 if ((fp = fopen (InFileName, "r")) == NULL)
64 { 66 {
65 fprintf (stderr, "\nError: can not open %s\n", InFileName); 67 fprintf (stderr, "\nError: can not open %s\n", InFileName);
88 object *tmp = NULL; 90 object *tmp = NULL;
89 int i; 91 int i;
90 92
91 switch (op->type) 93 switch (op->type)
92 { 94 {
93 case SHOP_FLOOR: 95 case SHOP_FLOOR:
94 if (!op->has_random_items ()) 96 if (!op->has_random_items ())
95 return 0; 97 return 0;
96 do 98 do
97 { 99 {
98 i = 10; /* let's give it 10 tries */ 100 i = 10; /* let's give it 10 tries */
99 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);
100 if (tmp == NULL) 102 if (tmp == NULL)
101 return 0; 103 return 0;
102 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 104 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
103 { 105 {
104 tmp->destroy (); 106 tmp->destroy ();
105 tmp = NULL; 107 tmp = NULL;
106 } 108 }
107 } 109 }
108 while (!tmp); 110 while (!tmp);
109 111
110 tmp->x = op->x, tmp->y = op->y; 112 tmp->x = op->x, tmp->y = op->y;
111 SET_FLAG (tmp, FLAG_UNPAID); 113 SET_FLAG (tmp, FLAG_UNPAID);
112 insert_ob_in_map (tmp, op->map, NULL, 0); 114 insert_ob_in_map (tmp, op->map, NULL, 0);
113 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 115 CLEAR_FLAG (op, FLAG_AUTO_APPLY);
114 identify (tmp); 116 identify (tmp);
115 break; 117 break;
116 118
117 case TREASURE: 119 case TREASURE:
118 if (op->has_random_items ()) 120 if (op->has_random_items ())
119 while ((op->stats.hp--) > 0) 121 while ((op->stats.hp--) > 0)
120 create_treasure (op->randomitems, op, GT_ENVIRONMENT, 122 create_treasure (op->randomitems, op, GT_ENVIRONMENT,
121 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);
122 op->remove (); 124 op->remove ();
123 op->destroy (); 125 op->destroy ();
124 break; 126 break;
125 } 127 }
126 128
127 return tmp ? 1 : 0; 129 return tmp ? 1 : 0;
128} 130}
129 131

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines