Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Pradip Fatehpuria Newsgroups: scea.yaroze.programming.codewarrior Subject: Re: Survival demo Date: Mon, 25 Aug 1997 18:03:23 -0700 Organization: Sony Computer Entertainment America Lines: 43 Message-ID: <34022B5B.6545@interactive.sony.com> References: <01bcb104$2433eea0$70bf43ce@wkwerner> NNTP-Posting-Host: 206.41.6.40 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01Gold (Win95; U) Wayne K. Werner wrote: > > 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 Yes, that is a mistake. Instead of "Enmy[i]." I should be using "objc->". So the line will look like the following (objc->Pos.coord.t[1] - objc->DifY + (*dy))) instead of (Enmy[i].Pos.coord.t[1] - Enmy[i].DifY + (*dy))) I will try to make the change soon and post it back. Pradip K Fatehpuria