Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "Chris Blackwell" Newsgroups: scea.yaroze.programming.codewarrior Subject: Re: Survival demo Date: 25 Aug 1997 12:15:48 GMT Organization: SCEA News Server Lines: 54 Message-ID: <01bcb151$44f05640$0f9f22cf@SmarttNet.smartt.com> References: <01bcb104$2433eea0$70bf43ce@wkwerner> NNTP-Posting-Host: vict-mx0100202.smartt.com X-Newsreader: Microsoft Internet News 4.70.1155 Examining the other functions, it looks like they forgot to put in the "check against all enemies loop", so it should probably look like this (the same detection sequence as in HandleRoboCollision()) for (i = 0; i < ENMY_NUM; i++) { short where = HandleObjcCollision(&Robo, &Enmy[i], dx, dy, dz); if (where & COLLISION_XYZ) { if ((Robo.Pos.coord.t[1] - Robo.DifY + (*dy)) <= (Enmy[i].Pos.coord.t[1] - Enmy[i].DifY)) enmyid = i; else roboid = 1; where_onenmy |= where; } } -Chris B. Wayne K. Werner wrote in article <01bcb104$2433eea0$70bf43ce@wkwerner>... > Didn't know where to post this, so I did it here... > > In converting the survival demo over to CW, I go a warning that the local > variable short i is used before it is initialized. This is indeed the > case, in the function HandleEnmyCollision() at line 1814 of main.c: > > static short HandleEnmyCollision(OBJECT *objc, short *dx, short *dy, short > *dz) > { > short i, slabid, ballid, enmyid, roboid; > short where_onwall, where_onslab, where_onball, where_onenmy, > where_onrobo; > short state = objc->State; > > /* Check the collision of the object with robot */ > roboid = -1; > where_onrobo = HandleObjcCollision(objc, &Robo, dx, dy, dz); > if (where_onrobo & COLLISION_XYZ) { > if ((Robo.Pos.coord.t[1] - Robo.DifY) <= > this is the offending line: > (Enmy[i].Pos.coord.t[1] - Enmy[i].DifY + (*dy))) > roboid = 0; > else > roboid = 1; > } > > What is the legitamate initialization value? > > Thanks, > Wayne K. Werner > wkwerner@con2.com > >