… | |
… | |
269 | retval = 15; |
269 | retval = 15; |
270 | else if (!strncasecmp (cp, query_base_name (op, 0), strlen (cp))) |
270 | else if (!strncasecmp (cp, query_base_name (op, 0), strlen (cp))) |
271 | retval = 14; |
271 | retval = 14; |
272 | else if (!strncasecmp (cp, query_base_name (op, 1), strlen (cp))) |
272 | else if (!strncasecmp (cp, query_base_name (op, 1), strlen (cp))) |
273 | retval = 14; |
273 | retval = 14; |
274 | |
|
|
275 | /* Do substring checks, so things like 'Str+1' will match. |
274 | /* Do substring checks, so things like 'Str+1' will match. |
276 | * retval of these should perhaps be lower - they are lower |
275 | * retval of these should perhaps be lower - they are lower |
277 | * then the specific strcasecmp aboves, but still higher than |
276 | * then the specific strcasecmp aboves, but still higher than |
278 | * some other match criteria. |
277 | * some other match criteria. |
279 | */ |
278 | */ |
… | |
… | |
281 | retval = 12; |
280 | retval = 12; |
282 | else if (strstr (query_base_name (op, 0), cp)) |
281 | else if (strstr (query_base_name (op, 0), cp)) |
283 | retval = 12; |
282 | retval = 12; |
284 | else if (strstr (query_short_name (op), cp)) |
283 | else if (strstr (query_short_name (op), cp)) |
285 | retval = 12; |
284 | retval = 12; |
286 | |
|
|
287 | /* Check against plural/non plural based on count. */ |
285 | /* Check against plural/non plural based on count. */ |
288 | else if (count > 1 && !strcasecmp (cp, op->name_pl)) |
286 | else if (count > 1 && !strcasecmp (cp, op->name_pl)) |
289 | { |
|
|
290 | retval = 6; |
287 | retval = 6; |
291 | } |
|
|
292 | else if (count == 1 && !strcasecmp (op->name, cp)) |
288 | else if (count == 1 && !strcasecmp (op->name, cp)) |
293 | { |
|
|
294 | retval = 6; |
289 | retval = 6; |
295 | } |
|
|
296 | /* base name matched - not bad */ |
290 | /* base name matched - not bad */ |
297 | else if (strcasecmp (cp, op->name) == 0 && !count) |
291 | else if (strcasecmp (cp, op->name) == 0 && !count) |
298 | retval = 4; |
292 | retval = 4; |
299 | /* Check for partial custom name, but give a real low priority */ |
293 | /* Check for partial custom name, but give a real low priority */ |
300 | else if (op->custom_name && strstr (op->custom_name, cp)) |
294 | else if (op->custom_name && strstr (op->custom_name, cp)) |
… | |
… | |
302 | |
296 | |
303 | if (retval) |
297 | if (retval) |
304 | { |
298 | { |
305 | if (pl->type == PLAYER) |
299 | if (pl->type == PLAYER) |
306 | pl->contr->count = count; |
300 | pl->contr->count = count; |
|
|
301 | |
307 | return retval; |
302 | return retval; |
308 | } |
303 | } |
309 | } |
304 | } |
|
|
305 | |
310 | return 0; |
306 | return 0; |
311 | } |
307 | } |
312 | |
308 | |
313 | /* |
309 | /* |
314 | * Initialises the internal linked list of archetypes (read from file). |
310 | * Initialises the internal linked list of archetypes (read from file). |
… | |
… | |
365 | |
361 | |
366 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
362 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
367 | add_arch (at); |
363 | add_arch (at); |
368 | |
364 | |
369 | LOG (llevDebug, "done\n"); |
365 | LOG (llevDebug, "done\n"); |
370 | } |
|
|
371 | |
|
|
372 | /* |
|
|
373 | * Dumps an archetype to debug-level output. |
|
|
374 | */ |
|
|
375 | |
|
|
376 | void |
|
|
377 | dump_arch (archetype *at) |
|
|
378 | { |
|
|
379 | dump_object (&at->clone); |
|
|
380 | } |
|
|
381 | |
|
|
382 | /* |
|
|
383 | * Dumps _all_ archetypes to debug-level output. |
|
|
384 | * If you run crossfire with debug, and enter DM-mode, you can trigger |
|
|
385 | * this with the O key. |
|
|
386 | */ |
|
|
387 | |
|
|
388 | void |
|
|
389 | dump_all_archetypes (void) |
|
|
390 | { |
|
|
391 | archetype *at; |
|
|
392 | |
|
|
393 | for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) |
|
|
394 | { |
|
|
395 | dump_arch (at); |
|
|
396 | fprintf (logfile, "%s\n", errmsg); |
|
|
397 | } |
|
|
398 | } |
366 | } |
399 | |
367 | |
400 | void |
368 | void |
401 | free_all_archs (void) |
369 | free_all_archs (void) |
402 | { |
370 | { |
… | |
… | |
549 | } |
517 | } |
550 | else if (!strcmp ("randomitems", variable)) |
518 | else if (!strcmp ("randomitems", variable)) |
551 | { |
519 | { |
552 | if (at != NULL) |
520 | if (at != NULL) |
553 | { |
521 | { |
554 | treasurelist * |
|
|
555 | tl = find_treasurelist (argument); |
522 | treasurelist *tl = find_treasurelist (argument); |
556 | |
523 | |
557 | if (tl == NULL) |
524 | if (tl == NULL) |
558 | LOG (llevError, "Failed to link treasure to arch (%s): %s\n", &at->name, argument); |
525 | LOG (llevError, "Failed to link treasure to arch (%s): %s\n", &at->name, argument); |
559 | else |
526 | else |
560 | at->clone.randomitems = tl; |
527 | at->clone.randomitems = tl; |