Re: Simple question

From: Michael Buselli (mhbusell@midway.uchicago.edu)
Date: 12/11/95


On Mon, 11 Dec 1995, Chris Crooker wrote:

> 	I was just wondering if my theory here works.  After the place 
> where height is determined in db.c for new characters, i added a 
> switch(GET_RACE(ch)) because i added races and i want the heights to 
> differ.  Can i just use:
> 
> switch (GET_RACE(ch)) {
> case RACE_HUMAN;
>     break;
> case RACE_BLAH;
>     ch->player.height *= .75;
>     break;
> etc..
> 
> This is just an example but will the multiplying by decimal work or am i 
> doing this wrong?  

I don't know if this works, but even if it does it's not the best way.  
Try something like

ch->player.height = ch->player.height * 3 / 4;

for faster code and code that is sure to work (fastest would be to use a
bit shift after the multiply).  By the way, don't mess with the order of
operations by adding ()'s.  To work right this has to perform the *3
before the /4.

Michael Buselli
mhbusell@midway.uchicago.edu



This archive was generated by hypermail 2b30 : 12/07/00 PST