ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_object.c
(Generate patch)

Comparing deliantra/server/server/c_object.c (file contents):
Revision 1.1.1.2 by elmex, Wed Feb 22 18:03:20 2006 UTC vs.
Revision 1.1.1.3 by elmex, Wed Mar 15 14:05:35 2006 UTC

1/* 1/*
2 * static char *rcsid_c_object_c = 2 * static char *rcsid_c_object_c =
3 * "$Id: c_object.c,v 1.1.1.2 2006/02/22 18:03:20 elmex Exp $"; 3 * "$Id: c_object.c,v 1.1.1.3 2006/03/15 14:05:35 elmex Exp $";
4 */ 4 */
5/* 5/*
6 CrossFire, A Multiplayer game for X-windows 6 CrossFire, A Multiplayer game for X-windows
7 7
8 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 8 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
52 }\ 52 }\
53 last->next=NULL;\ 53 last->next=NULL;\
54 last->ob=(NEW);\ 54 last->ob=(NEW);\
55 last->id=(COUNT); 55 last->id=(COUNT);
56 56
57/**
57/* Search the inventory of 'pl' for what matches best with params. 58 * Search the inventory of 'pl' for what matches best with params.
58 * we use item_matched_string above - this gives us consistent behaviour 59 * we use item_matched_string above - this gives us consistent behaviour
59 * between many commands. Return the best match, or NULL if no match. 60 * between many commands. Return the best match, or NULL if no match.
61 * aflag is used with apply -u , and apply -a to
62 * only unapply applied, or apply unapplied objects
60 */ 63 **/
61object *find_best_object_match(object *pl, const char *params) 64static object *find_best_apply_object_match(object *pl, const char *params, enum apply_flag aflag)
62{ 65{
63 object *tmp, *best=NULL; 66 object *tmp, *best=NULL;
64 int match_val=0,tmpmatch; 67 int match_val=0,tmpmatch;
65 68
66 for (tmp=pl->inv; tmp; tmp=tmp->below) { 69 for (tmp=pl->inv; tmp; tmp=tmp->below) {
67 if (tmp->invisible) continue; 70 if (tmp->invisible) continue;
68 if ((tmpmatch=item_matched_string(pl, tmp, params))>match_val) { 71 if ((tmpmatch=item_matched_string(pl, tmp, params))>match_val) {
72 if ((aflag==AP_APPLY) && (QUERY_FLAG(tmp,FLAG_APPLIED))) continue;
73 if ((aflag==AP_UNAPPLY) && (!QUERY_FLAG(tmp,FLAG_APPLIED))) continue;
69 match_val=tmpmatch; 74 match_val=tmpmatch;
70 best=tmp; 75 best=tmp;
71 } 76 }
72 } 77 }
73 return best; 78 return best;
74} 79}
75/* Simlilar to find_best_object_match , but accepts an 80
76 * additional parameter for apply -u , and apply -a to 81/**
77 * only unapply applied , or apply unapplied objects 82 * Shortcut to find_best_apply_object_match(pl, params, AF_NULL);
78 */ 83 **/
79static object *find_best_apply_object_match(object *pl, char *params, enum apply_flag aflag) 84object *find_best_object_match(object *pl, const char *params)
80{ 85{
81 object *tmp, *best=NULL; 86 return find_best_apply_object_match(pl, params, AP_NULL);
82 int match_val=0,tmpmatch;
83
84 for (tmp=pl->inv; tmp; tmp=tmp->below) {
85 if (tmp->invisible) continue;
86 if ((tmpmatch=item_matched_string(pl, tmp, params))>match_val) {
87 if ((aflag==AP_APPLY) && (QUERY_FLAG(tmp,FLAG_APPLIED))) continue;
88 if ((aflag==AP_UNAPPLY) && (!QUERY_FLAG(tmp,FLAG_APPLIED))) continue;
89 match_val=tmpmatch;
90 best=tmp;
91 }
92 }
93 return best;
94} 87}
95 88
96/* 89/*
97 * Notes about item creation: 90 * Notes about item creation:
98 * 1) It is similar in syntax to the dm create command. 91 * 1) It is similar in syntax to the dm create command.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines