View Single Post
  #10  
Old 11-30-2008, 04:25 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Why did you not just store mountspeed as a float? Why do this extra work when you could just do:

Code:
npc_type->runspeed = atof(row[3])
Here's an explanation of what's going wrong with your runspeed by doing it this way:
Code:
npc_type->runspeed = mountspeed / 100;

if it's 125:
npc_type->runspeed = 125 / 100;
npc_type->runspeed = 1

if it's 100:
npc_type->runspeed = 100 / 100; 
npc_type->runspeed = 1

if it's 75:
npc_type->runspeed = 75 / 100;
npc_type->runspeed = 0
None of them are floats and ints will not do any rounding for you if it comes up with a partial during a divide it is dropped. Unless you cast the variables to float first you're not going to get anywhere.

Also there's no reason to assign temp variables to hold the information from db as you don't do anything else with it, you're plugging it straight into the NPCType. Waste of time and memory however small it may be.

Last edited by KLS; 12-01-2008 at 12:33 AM..
Reply With Quote