Re: Simple question

From: d. hall (
Date: 12/12/95

 thus on Tue, 12 Dec 1995 00:42:46 -0600 (CST), Michael virtually scripted...

> 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?  

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

it does work with GCC, since it's smart enough to implicitly typecast.

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

this might save the work of typecasting, but it varies based upon the
platform and compiler.

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

yes, this would seem to be the most portible.

``if you're so perfect, try walking on water some time.''
					- another anonymous quote

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