ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/treasure.C
(Generate patch)

Comparing deliantra/server/common/treasure.C (file contents):
Revision 1.68 by root, Thu Nov 8 19:43:23 2007 UTC vs.
Revision 1.71 by root, Tue Apr 15 03:16:02 2008 UTC

139 139
140 f.next (); 140 f.next ();
141 141
142 for (;;) 142 for (;;)
143 { 143 {
144 coroapi::cede_to_tick_every (10); 144 coroapi::cede_to_tick ();
145 145
146 switch (f.kw) 146 switch (f.kw)
147 { 147 {
148 case KW_arch: 148 case KW_arch:
149 t->item = archetype::get (f.get_str ()); 149 t->item = archetype::get (f.get_str ());
1128 * Allocate and return the pointer to an empty artifactlist structure. 1128 * Allocate and return the pointer to an empty artifactlist structure.
1129 */ 1129 */
1130static artifactlist * 1130static artifactlist *
1131get_empty_artifactlist (void) 1131get_empty_artifactlist (void)
1132{ 1132{
1133 return salloc0 <artifactlist> (); 1133 return salloc0<artifactlist> ();
1134} 1134}
1135 1135
1136/* 1136/*
1137 * Allocate and return the pointer to an empty artifact structure. 1137 * Allocate and return the pointer to an empty artifact structure.
1138 */ 1138 */
1139static artifact * 1139static artifact *
1140get_empty_artifact (void) 1140get_empty_artifact (void)
1141{ 1141{
1142 return salloc0 <artifact> (); 1142 return salloc0<artifact> ();
1143} 1143}
1144 1144
1145/* 1145/*
1146 * Searches the artifact lists and returns one that has the same type 1146 * Searches the artifact lists and returns one that has the same type
1147 * of objects on it. 1147 * of objects on it.
1152 for (artifactlist *al = first_artifactlist; al; al = al->next) 1152 for (artifactlist *al = first_artifactlist; al; al = al->next)
1153 if (al->type == type) 1153 if (al->type == type)
1154 return al; 1154 return al;
1155 1155
1156 return 0; 1156 return 0;
1157}
1158
1159/*
1160 * For debugging purposes. Dumps all tables.
1161 */
1162void
1163dump_artifacts (void)
1164{
1165 artifactlist *al;
1166 artifact *art;
1167 linked_char *next;
1168
1169 fprintf (logfile, "\n");
1170 for (al = first_artifactlist; al != NULL; al = al->next)
1171 {
1172 fprintf (logfile, "Artifact has type %d, total_chance=%d\n", al->type, al->total_chance);
1173 for (art = al->items; art != NULL; art = art->next)
1174 {
1175 fprintf (logfile, "Artifact %-30s Difficulty %3d Chance %5d\n", &art->item->name, art->difficulty, art->chance);
1176 if (art->allowed != NULL)
1177 {
1178 fprintf (logfile, "\tallowed combinations:");
1179 for (next = art->allowed; next != NULL; next = next->next)
1180 fprintf (logfile, "%s,", &next->name);
1181 fprintf (logfile, "\n");
1182 }
1183 }
1184 }
1185 fprintf (logfile, "\n");
1186}
1187
1188/*
1189 * For debugging purposes. Dumps all treasures recursively (see below).
1190 */
1191void
1192dump_monster_treasure_rec (const char *name, treasure *t, int depth)
1193{
1194 treasurelist *tl;
1195 int i;
1196
1197 if (depth > 100)
1198 return;
1199
1200 while (t)
1201 {
1202 if (t->name)
1203 {
1204 for (i = 0; i < depth; i++)
1205 fprintf (logfile, " ");
1206
1207 fprintf (logfile, "{ (list: %s)\n", &t->name);
1208
1209 tl = treasurelist::find (t->name);
1210 if (tl)
1211 dump_monster_treasure_rec (name, tl->items, depth + 2);
1212
1213 for (i = 0; i < depth; i++)
1214 fprintf (logfile, " ");
1215
1216 fprintf (logfile, "} (end of list: %s)\n", &t->name);
1217 }
1218 else
1219 {
1220 for (i = 0; i < depth; i++)
1221 fprintf (logfile, " ");
1222
1223 if (t->item && t->item->type == FLESH)
1224 fprintf (logfile, "%s's %s\n", name, &t->item->object::name);
1225 else
1226 fprintf (logfile, "%s\n", &t->item->object::name);
1227 }
1228
1229 if (t->next_yes)
1230 {
1231 for (i = 0; i < depth; i++)
1232 fprintf (logfile, " ");
1233
1234 fprintf (logfile, " (if yes)\n");
1235 dump_monster_treasure_rec (name, t->next_yes, depth + 1);
1236 }
1237
1238 if (t->next_no)
1239 {
1240 for (i = 0; i < depth; i++)
1241 fprintf (logfile, " ");
1242
1243 fprintf (logfile, " (if no)\n");
1244 dump_monster_treasure_rec (name, t->next_no, depth + 1);
1245 }
1246
1247 t = t->next;
1248 }
1249}
1250
1251/*
1252 * For debugging purposes. Dumps all treasures for a given monster.
1253 * Created originally by Raphael Quinet for debugging the alchemy code.
1254 */
1255void
1256dump_monster_treasure (const char *name)
1257{
1258 archetype *at;
1259 int found;
1260
1261 found = 0;
1262 fprintf (logfile, "\n");
1263
1264 for_all_archetypes (at)
1265 if (!strcasecmp (at->object::name, name) && at->title == NULL)
1266 {
1267 fprintf (logfile, "treasures for %s (arch: %s)\n", &at->object::name, &at->archname);
1268 if (at->randomitems != NULL)
1269 dump_monster_treasure_rec (at->object::name, at->randomitems->items, 1);
1270 else
1271 fprintf (logfile, "(nothing)\n");
1272
1273 fprintf (logfile, "\n");
1274 found++;
1275 }
1276
1277 if (found == 0)
1278 fprintf (logfile, "No objects have the name %s!\n\n", name);
1279} 1157}
1280 1158
1281/* 1159/*
1282 * Builds up the lists of artifacts from the file in the libdir. 1160 * Builds up the lists of artifacts from the file in the libdir.
1283 */ 1161 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines