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.39 by root, Wed May 9 11:32:31 2007 UTC vs.
Revision 1.40 by root, Fri May 11 20:06:33 2007 UTC

234} 234}
235 235
236/* This changes the objects skill to new_skill. 236/* This changes the objects skill to new_skill.
237 * note that this function doesn't always need to get used - 237 * note that this function doesn't always need to get used -
238 * you can now add skill exp to the player without the chosen_skill being 238 * you can now add skill exp to the player without the chosen_skill being
239 * set. This function is of most interest to players to update 239 * set. This function is of most interest to players to update
240 * the various range information. 240 * the various range information.
241 * return 1 on success, 0 on error 241 * return 1 on success, 0 on error
242 */ 242 */
243int 243int
244change_skill (object *who, object *new_skill, int flag) 244change_skill (object *who, object *new_skill, int flag)
245{ 245{
246 if (who->type != PLAYER) 246 if (who->type != PLAYER)
247 return 0; 247 return 0;
248
249 // optimise this supposedly common case
250 if (new_skill == who->chosen_skill)
251 return 1;
252
253 fprintf (stderr, "cs from %s to %s\n", who->chosen_skill ? &who->chosen_skill->name : 0,
254 new_skill ? &new_skill->name : 0);//D//D//D
255
256 if (who->chosen_skill)
257 apply_special (who, who->chosen_skill, AP_UNAPPLY);
248 258
249 if (!new_skill) 259 if (!new_skill)
250 { 260 {
251 LOG (llevError | logBacktrace, "change_skill called on %s with NULL skill\n", 261 LOG (llevError | logBacktrace, "change_skill called on %s with NULL skill\n",
252 who->debug_desc ()); 262 who->debug_desc ());
253 return 0; 263 return 0;
254 } 264 }
255 265
256 player *pl = who->contr; 266 player *pl = who->contr;
257 267
258 // move skill to front, so it will be preferred next time 268 // move skill to front, so it will be prefered next time
259 new_skill->remove (); 269 new_skill->remove ();
260 who->insert (new_skill); 270 who->insert (new_skill);
261 271
262 if (apply_special (who, new_skill, AP_APPLY)) 272 if (apply_special (who, new_skill, AP_APPLY))
263 return 0; 273 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines