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

Comparing deliantra/server/server/skill_util.C (file contents):
Revision 1.42 by root, Sat May 12 08:36:35 2007 UTC vs.
Revision 1.43 by root, Sat May 12 13:27:38 2007 UTC

167 } 167 }
168 168
169 return 0; 169 return 0;
170} 170}
171 171
172
173/* This returns the skill pointer of the given name (the 172/* This returns the skill pointer of the given name (the
174 * one that accumlates exp, has the level, etc). 173 * one that accumlates exp, has the level, etc).
175 * 174 *
176 * It is presumed that the player will be needing to actually 175 * It is presumed that the player will be needing to actually
177 * use the skill, so thus if use of the skill requires a skill 176 * use the skill, so thus if use of the skill requires a skill
261 LOG (llevError | logBacktrace, "change_skill called on %s with NULL skill\n", 260 LOG (llevError | logBacktrace, "change_skill called on %s with NULL skill\n",
262 who->debug_desc ()); 261 who->debug_desc ());
263 return 0; 262 return 0;
264 } 263 }
265 264
266 player *pl = who->contr; 265 new_skill->inv_splay ();
267
268 // move skill to front, so it will be prefered next time
269 new_skill->remove ();
270 who->insert (new_skill);
271 266
272 if (apply_special (who, new_skill, AP_APPLY)) 267 if (apply_special (who, new_skill, AP_APPLY))
273 return 0; 268 return 0;
274 269
275 return 1; 270 return 1;
302int 297int
303do_skill (object *op, object *part, object *skill, int dir, const char *string) 298do_skill (object *op, object *part, object *skill, int dir, const char *string)
304{ 299{
305 int success = 0, exp = 0; 300 int success = 0, exp = 0;
306 int did_alc = 0; 301 int did_alc = 0;
307 object *tmp, *next;
308 302
309 if (!skill) 303 if (!skill)
310 return 0; 304 return 0;
311 305
312 /* The code below presumes that the skill points to the object that 306 /* The code below presumes that the skill points to the object that
314 * go and try to find the actual real skill pointer, and if the 308 * go and try to find the actual real skill pointer, and if the
315 * the player doesn't have a bucket for that, create one. 309 * the player doesn't have a bucket for that, create one.
316 */ 310 */
317 if (skill->type != SKILL && op->type == PLAYER) 311 if (skill->type != SKILL && op->type == PLAYER)
318 { 312 {
319 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 313 for (object *tmp = op->inv; tmp; tmp = tmp->below)
320 if (tmp->type == SKILL && tmp->skill == skill->skill) 314 if (tmp->type == SKILL && tmp->skill == skill->skill)
321 break; 315 {
316 skill = tmp;
317 goto found;
318 }
322 319
323 if (!tmp)
324 tmp = give_skill_by_name (op, skill->skill); 320 skill = give_skill_by_name (op, skill->skill);
325 321found: ;
326 skill = tmp;
327 } 322 }
328 323
329 // skill, by_whom, on_which_object, which direction, skill_argument 324 // skill, by_whom, on_which_object, which direction, skill_argument
330 if (INVOKE_OBJECT (USE_SKILL, skill, ARG_OBJECT (op), ARG_OBJECT (part), ARG_INT (dir), ARG_STRING (string))) 325 if (INVOKE_OBJECT (USE_SKILL, skill, ARG_OBJECT (op), ARG_OBJECT (part), ARG_INT (dir), ARG_STRING (string)))
331 return 0; 326 return 0;
436 case SK_LITERACY: 431 case SK_LITERACY:
437 case SK_WOODSMAN: 432 case SK_WOODSMAN:
438 /* first, we try to find a cauldron, and do the alchemy thing. 433 /* first, we try to find a cauldron, and do the alchemy thing.
439 * failing that, we go and identify stuff. 434 * failing that, we go and identify stuff.
440 */ 435 */
441 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = next) 436 for (object *next, *tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = next)
442 { 437 {
443 next = tmp->above; 438 next = tmp->above;
444 439
445 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 440 if (QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
446 { 441 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines