Problems with act_object.c

Posted by Creeper386 on Mon 22 Apr 2002 02:06 AM — 9 posts, 27,955 views.

USA #0
Okay first off I'm running Cygwin B20, Win98 machine.

I'm trying Sadiq's changes for a clean compile getting rid of all the stupid little errors mostly the 'suggest braces' warnings, and the 'comparison always zero' warnings.

I know it would still compile but a clean compile would be nice.

I have already made the changes suggested on Garwain's site for compiling smaug 1.4a on cygwin b20 but the site seems to have dissapeared of the net but luckily I had a soft copy on one of my comps, I compiled it after these changes and it worked just fine.

Now I made the changes from Sadiq's site:
( http://sadiq.adahost.com/smaug_winport.txt )

And the first changes work but I come to act_obj.c and I get the following:


act_obj.c: In function `do_auction':
act_obj.c:2903: parse error before `void'
act_obj.c:2911: `is_falling' undeclared (first use in this function)
act_obj.c:2911: (Each undeclared identifier is reported only once
act_obj.c:2911: for each function it appears in.)
act_obj.c:2914: `fall_count' undeclared (first use in this function)
act_obj.c:2927: `pexit' undeclared (first use in this function)
act_obj.c:2928: `to_room' undeclared (first use in this function)
act_obj.c:2930: `through' undeclared (first use in this function)
make[1]: *** [act_obj.o] Error 1
make: *** [all] Error 2



Any help would be appreciated, and thank you ahead of time,

Creeper
Australia Forum Administrator #1
Very hard to say without seeing the source. Try posting lines 2900 to 2920 of your source.
USA #2
I beleive this is the part where there is a problem but I'm not sure. Doesn't look like any part that I edited...



/* Make objects in rooms that are nofloor fall - Scryn 1/23/96 */

void obj_fall( OBJ_DATA *obj, bool through )
{
    EXIT_DATA *pexit;
    ROOM_INDEX_DATA *to_room;
    static int fall_count;
    char buf[MAX_STRING_LENGTH];
    static bool is_falling; /* Stop loops from the call to obj_to_room()  -- A

    if ( !obj->in_room || is_falling )
        return;

    if (fall_count > 30)
    {
        bug( "object falling in loop more than 30 times", 0 );
        extract_obj(obj);
        fall_count = 0;
        return;
     }
Australia Forum Administrator #3
The error message said the problem was in function do_auction, however you have posted obj_fall.
USA #4
Those are lines 2900 to 2920 or right around there.. And it also contains all the is_falling and such like that that it is saying that it's the first time it's being used. do_auction is around 2482 or so. Thats another reason why I don't really understand the error message. Because I edited something in do auction adding brackets but didn't change anything in obj_fall. I'll post the whole do_auction in the next post.

Okay never mind about posting it.. It is way too long to stick on here. If I can find it I'll show you the changes I made in there.. Just hoping I can get to Sadiq's site again.

Creep
Amended on Tue 23 Apr 2002 06:34 AM by Creeper386
USA #5
I think the problem was that area in the code was just fine and so Sadiq's fixings there was unneccessary giving too many braces in that area because I replace to act_obj.c with the original one and there is only three problems with the braces and that isn't in do_auction. Besides those three braces problems I have something about an unused variable buf which I'm going to look into next. Trying to get a completely clean compile before I get going with other things. So I know there aren't any problems except things I make....

I'll be back I'm sure... But hopefully I'll figure this out on my own... After this I'm planning on making an alternative to the slist going to make a section for everything someone like taking practice and splitting it up.. Planning on using the code for practice to get it done.

Thanks again,

Creep
Australia Forum Administrator #6
Ah I see. If you have been fiddling around adding or removing braces then that might well happen. Just adding one extra brace effectively can cause the compiler to "not see" a function definition, and eventually give the error message it did, somewhat further on than it should.

Some editors have a "match braces" function (including MUSHclient's notepad) - you can use that to see if braces end where they should.
USA #7
Where is Mush Notepad?

Also do you know anything about unused variables and why they would come up? Rather know what exactly they are then just how to fix a specific one.

Thanks for the help.

Creep
Australia Forum Administrator #8
Use the Edit Menu -> Notepad (Ctrl+Alt+W).

Or, Flip To Notepad (Ctrl+Alt+Space).

Then you can use the Edit menu (in the Notepad) and "Go to matching brace" (Ctrl+E) or "select to matching brace" (Shift+Ctrl+E).

You may need to fiddle with the General Preferences -> Notepad configuration to tell it how to do the brace matching.

For example, for C code, you would probably have:


[X] Braces nest
[X] \ escapes next character
[ ] % escapes next character
[X] ' quotes a string   [X] ... with escape inside quotes
[X] " quotes a string   [X] ... with escape inside quotes 


As for unused variables, they will be because the programmer declared a variable but never used it. They do no harm, but can be confusing. eg.


int myfunction (int i, int j)
  {
  int k;
  int m;

  k = i + j;
  return k;
  }


In the example above the variable "m" is never used, and would generate that warning. You could delete the declaration for it.