View Single Post
  #1  
Old 01-20-2015, 02:24 PM
iluvseq
Sarnak
 
Join Date: Aug 2009
Location: Somewhere
Posts: 53
Default COMMITTED: Sprintf bug in SKILLS__GAIN log message

The patch below fixes a sprintf() format bug in SKILLS__GAIN log messages. The current code formats with %.4f but 'Chance' is actually an int32 so it gets skipped as an input parameter, causing the log message to put Chance in the (mod X) position and chancemodi to never be logged at all.

Code:
--- a/zone/client.cpp
+++ b/zone/client.cpp
@@ -2232,10 +2232,10 @@ bool Client::CheckIncreaseSkill(SkillUseTypes skillid, Mob *against_who, int cha
    if(zone->random.Real(0, 99) < Chance)
    {
      SetSkill(skillid, GetRawSkill(skillid) + 1);
-     _log(SKILLS__GAIN, "Skill %d at value %d successfully gain with %.4f%%chance (mod %d)", skillid, skillval, Chance, chancemodi);
+     _log(SKILLS__GAIN, "Skill %d at value %d successfully gain with %d%% chance (mod %d)", skillid, skillval, Chance, chancemodi);
      return true;
    } else {
-     _log(SKILLS__GAIN, "Skill %d at value %d failed to gain with %.4f%%chance (mod %d)", skillid, skillval, Chance, chancemodi);
+     _log(SKILLS__GAIN, "Skill %d at value %d failed to gain with %d%% chance (mod %d)", skillid, skillval, Chance, chancemodi);
    }
  } else {
    _log(SKILLS__GAIN, "Skill %d at value %d cannot increase due to maxmum %d", skillid, skillval, maxskill);

Last edited by joligario; 01-20-2015 at 04:32 PM..
Reply With Quote