Need Help Compiling SWR

Posted by Raistlen on Wed 18 Jun 2003 10:07 AM — 21 posts, 75,764 views.

#0
Hello, I'm new here, I tried searching for other posts about this but haven't found any. If this was covered before, I apologize and could gladly use a pointer in the right direction. :P

Heres the problem, I am trying to compile pure stock SWR code. I had managed to compile and run it fine on cygwin, no problem. The trouble comes when I'm now trying to compile it on a native Linux enviorenment.

The compiler will compile all the files except act_wiz.c, and here is the error dump I recieve.


[16:07](raistlen@linux src)$ make
make swreality
make[1]: Entering directory `/home/raistlen/dist/src'
gcc -c -g3 -Wall    act_wiz.c
act_wiz.c:2355:22: missing terminating " character
act_wiz.c: In function `do_balzhur':
act_wiz.c:2356: error: parse error before "Thoric"
act_wiz.c:2356: error: stray '\' in program
act_wiz.c:2356: error: stray '\' in program
act_wiz.c:2356:11: missing terminating " character
act_wiz.c:2372:25: missing terminating " character
act_wiz.c:2373: error: parse error before "backup"
act_wiz.c:2373: error: `backup' undeclared (first use in this function)
act_wiz.c:2373: error: (Each undeclared identifier is reported only once
act_wiz.c:2373: error: for each function it appears in.)
act_wiz.c:2373: error: stray '\' in program
act_wiz.c:2373: error: stray '\' in program
act_wiz.c:2373: error: parse error before "r"
act_wiz.c:2373:12: missing terminating " character
act_wiz.c:2376:26: missing terminating " character
act_wiz.c:2377: error: stray '\' in program
act_wiz.c:2377: error: stray '\' in program
act_wiz.c:2377:12: missing terminating " character
act_wiz.c: At top level:
act_wiz.c:2385: warning: type defaults to `int' in declaration of `make_wizlist'
act_wiz.c:2385: error: conflicting types for `make_wizlist'
mud.h:4299: error: previous declaration of `make_wizlist'
act_wiz.c:2385: warning: data definition has no type or storage class
act_wiz.c:2386: error: parse error before string constant
act_wiz.c:2386: warning: type defaults to `int' in declaration of `do_help'
act_wiz.c:2386: error: conflicting types for `do_help'
mud.h:3561: error: previous declaration of `do_help'
act_wiz.c:2386: warning: data definition has no type or storage class
act_wiz.c:2387: error: parse error before numeric constant
act_wiz.c:2387: warning: type defaults to `int' in declaration of `set_char_colo
r'
act_wiz.c:2387: error: conflicting types for `set_char_color'
mud.h:4234: error: previous declaration of `set_char_color'
act_wiz.c:2387: warning: data definition has no type or storage class
act_wiz.c:2388: error: parse error before string constant
act_wiz.c:2388: warning: type defaults to `int' in declaration of `send_to_char_
color'
act_wiz.c:2388: error: conflicting types for `send_to_char_color'
mud.h:4231: error: previous declaration of `send_to_char_color'
act_wiz.c:2388: warning: data definition has no type or storage class
make[1]: *** [act_wiz.o] Error 1
make[1]: Leaving directory `/home/raistlen/dist/src'
make: *** [all] Error 2


Any help would be greatly appreciated. =)

P.S

make version: GNU Make 3.80
GCC version: (GCC) 3.3 (Debian)
Amended on Wed 18 Jun 2003 12:47 PM by Raistlen
USA #1
As helpful as the error messages might be, without the code most of us really cant help much :( Paste in the relevant section of act_wiz and I'd bet its probly an easy fix once we have the code.
#2
Not all files compiled correctly either (well...not for sure). You should type 'make -k' without the ' to compile all possible. Either copy/paste the code at fault or give us the source. Then we can help you. :)
#3
The act_wiz.c im using is pure stock, I never touched it, but here is the relevent code section.

starting from 2349 and ending in 2392.


    sprintf( buf, "%s%s", GOD_DIR, capitalize(victim->name) );  
 
    if ( !remove( buf ) )
      send_to_char( "Player's immortal data destroyed.\n\r", ch );
    else if ( errno != ENOENT )
    {
      ch_printf( ch, "Unknown error #%d - %s (immortal data).  Report to 
Thoric\n\r",
              errno, strerror( errno ) );
      sprintf( buf2, "%s balzhuring %s", ch->name, buf );
      perror( buf2 );
    }
    sprintf( buf2, "%s.are", capitalize(arg) );
    for ( pArea = first_build; pArea; pArea = pArea->next )
      if ( !strcmp( pArea->filename, buf2 ) )
      {
        sprintf( buf, "%s%s", BUILD_DIR, buf2 );
        if ( IS_SET( pArea->status, AREA_LOADED ) )
          fold_area( pArea, buf, FALSE );
        close_area( pArea );
        sprintf( buf2, "%s.bak", buf );
        set_char_color( AT_RED, ch ); /* Log message changes colors */
        if ( !rename( buf, buf2 ) )
          send_to_char( "Player's area data destroyed.  Area saved as 
backup.\n\r", ch);
        else if ( errno != ENOENT )
        {
          ch_printf( ch, "Unknown error #%d - %s (area data).  Report to 
Thoric.\n\r",
                  errno, strerror( errno ) );
          sprintf( buf2, "%s destroying %s", ch->name, buf );
          perror( buf2 );   
        }
      }
 
 
        make_wizlist();
	do_help(victim, "M_BALZHUR_" );
	set_char_color( AT_WHITE, victim );
	send_to_char( "You awake after a long period of time...\n\r", victim );
	while ( victim->first_carrying )
	     extract_obj( victim->first_carrying );
    return;
}
#4
change those lines to:




sprintf( buf, "%s%s", GOD_DIR, capitalize(victim->name) );

if ( !remove( buf ) )
send_to_char( "Player's immortal data destroyed.\n\r", ch );
else if ( errno != ENOENT )
{
ch_printf( ch, "Unknown error #%d - %s (immortal data). Report to Thoric\n\r",
errno, strerror( errno ) );
sprintf( buf2, "%s balzhuring %s", ch->name, buf );
perror( buf2 );
}
sprintf( buf2, "%s.are", capitalize(arg) );
for ( pArea = first_build; pArea; pArea = pArea->next )
if ( !strcmp( pArea->filename, buf2 ) )
{
sprintf( buf, "%s%s", BUILD_DIR, buf2 );
if ( IS_SET( pArea->status, AREA_LOADED ) )
fold_area( pArea, buf, FALSE );
close_area( pArea );
sprintf( buf2, "%s.bak", buf );
set_char_color( AT_RED, ch ); /* Log message changes colors */
if ( !rename( buf, buf2 ) )
send_to_char( "Player's area data destroyed. Area saved as backup.\n\r", ch);
else if ( errno != ENOENT )
{
ch_printf( ch, "Unknown error #%d - %s (area data). Report to Thoric.\n\r",
errno, strerror( errno ) );
sprintf( buf2, "%s destroying %s", ch->name, buf );
perror( buf2 );
}
}


make_wizlist();
do_help(victim, "M_BALZHUR_" );
set_char_color( AT_WHITE, victim );
send_to_char( "You awake after a long period of time...\n\r", victim );
while ( victim->first_carrying )
extract_obj( victim->first_carrying );
return;
}

and see what you get. I deleted a few of the spaces between lines (meaning the thoric line, there was an enter instead of a space there).
#5
Its working now, thank you so much. =D
#6
Hey again, I'm trying to compile the SWRip, and im getting more errors on pure stock code. The error is


misc.c:3209: error: invalid operands to binary +
misc.c:4081:2: warning: no newline at end of file
make[1]: *** [misc.o] Error 1
make[1]: Leaving directory `/home/raistlen/swrip/src'
make: *** [all] Error 2


And the relevent sections are


int add_bad_name(char *name)
{
  FILE *fp;
  char *ln;
  fpos_t pos;

  if (check_bad_name(name))
    return 0;

  if ((fp = fopen(BAD_NAME_FILE,"r+")) == NULL)
  {
    bug("Error opening Bad Name file.");
    return -1;
  }

  ln = fread_string_nohash(fp);
  while(!is_name("$",ln) && !feof(fp))
      ln = fread_string_nohash(fp);

  /* Delete the $~ from the end of the file */
  fgetpos(fp, &pos);
  pos += -2;
  fsetpos(fp, &pos);
  fprintf(fp,"%s~\n",name);
  fprintf(fp,"$~");
  fclose(fp);
  return 1;
}


With the " pos += -2;" being the line generating the error.

the second error, end file, il just paste the end of the file, i suppose.

Here is how the file ends.


	        ch->nextquest = 30;
	        sprintf(buf, "You have run out of time for your quest!\n\rYou may quest again in %d minutes.\n\r",ch->nextquest);
	        send_to_char(buf, ch);
                REMOVE_BIT(ch->act, PLR_QUESTOR);
                ch->questgiver = NULL;
                ch->countdown = 0;
                ch->questmob = 0;
	    }
	    if (ch->countdown > 0 && ch->countdown < 6)
	    {
	        send_to_char("Better hurry, you're almost out of time for your quest!\n\r",ch);
	        return;
	    }
        }
    }
    return;
}



Any help would be greatly appreciated, as always. =)
Amended on Sun 22 Jun 2003 07:46 PM by Raistlen
USA #7
Hrm, first one is just wierd, try changing the offending like to pos++ -2. As for the 2nd, at the end of the file just hit enter to put a newline at the end of the file.
#8
That change yields:


misc.c: In function `add_bad_name':
misc.c:3209: error: wrong type argument to increment
make[1]: *** [misc.o] Error 1
make[1]: Leaving directory `/home/raistlen/swrip/src'
make: *** [all] Error 2
USA #9
K, try changing from pos += -2 to pos -= 2 and lemme know what happens
#10
That gives:


misc.c: In function `add_bad_name':
misc.c:3209: error: invalid operands to binary -
make[1]: *** [misc.o] Error 1
make[1]: Leaving directory `/home/raistlen/swrip/src'
make: *** [all] Error 2
USA #11
Hrm... what are the includes for that file while Im thinking about it, that error is just too bazaar not to have an easy to miss cause.
#12
The includes are:


#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"

USA #13
try adding math.h to the includes and see what happens
#14
Same deal as the very first one.


misc.c:3210: error: invalid operands to binary +
make[1]: *** [misc.o] Error 1
make[1]: Leaving directory `/home/raistlen/swrip/src'
make: *** [all] Error 2

Australia Forum Administrator #15
I just pasted the add_bad_name code you had above into stock SMAUG's misc.c and it compiled OK, so there is nothing wrong with the code as such.The only things I can suggest are:

1. Some bad characters have snuck into the source file, try copying and pasting yourself and see if the problem goes away (eg. from this web page).

2. There is a "define" that changes the meaning of fpos_t or pos.

3. You are using some really out-of-date compiler - which one are you using and on what operating system?

4. You don't have an include for stdio.h which defines fpos_t.
#16
First off, thanks for your time and patiance. I honestly don't know the first thing about coding, but I'll try my best to follow along.

Quote:
1. Some bad characters have snuck into the source file, try copying and pasting yourself and see if the problem goes away (eg. from this web page).


The source file I'm using is downloaded right from http://www.geocities.com/gendi_uk/files/swrip.tar.gz and I havent changed a single character except for the advice offered here. I searched for this same code in stock SMAUG and SWR, and coudn't find any to replace it with. I suppose this is SWRip specific?

Quote:
2. There is a "define" that changes the meaning of fpos_t or pos.


I'm afraid thats code work that I'm not too familiar with. What should I look for, and where?

Quote:
3. You are using some really out-of-date compiler - which one are you using and on what operating system?


My operating versions were listed as a P.S on my very first post, but I'll repost it. :-P

make version: GNU Make 3.80
GCC version: (GCC) 3.3 (Debian)

Quote:
4. You don't have an include for stdio.h which defines fpos_t.


Glancing at the top of the misc.c file, looks like I do. Is there someplace else to look at? :-/


I appreciated the patiance. :)

-Raist
Australia Forum Administrator #17
Hmmm - a fascinating problem. :)

I compiled it OK on my Mac OS/X and was about to tell you to try again, but then I tried on RedHat Linux and reproduced the problem. ;)

If you type "man fgetpos" you get a clue, here is the relevant section:


The fgetpos and fsetpos functions are alternate  interfaces  equivalent
to  ftell  and fseek (with whence set to SEEK_SET), setting and storing
the current value of the file offset into or from the object referenced
by  pos.   On  some  non-UNIX systems an fpos_t object may be a complex
object and these routines may be the only way to portably reposition  a
text stream.


Relevant sentence in bold. It is indeed a complex structure, like this:


typedef struct
{
  __off_t __pos;
  __mbstate_t __state;
} _G_fpos_t;
typedef struct
{
  __off64_t __pos;
  __mbstate_t __state;
} _G_fpos64_t;

#ifndef __USE_FILE_OFFSET64
typedef _G_fpos_t fpos_t;
#else
typedef _G_fpos64_t fpos_t;
#endif



You cannot add or subtract from a structure, that is why you are getting the error.

I suggest changing the line and line after to this:


//  pos += -2;
//  fsetpos(fp, &pos);
  fseek(fp, -2, SEEK_CUR);


That is, comment out the "subtract 2" and the next line which sets the position, and replace with fseek, which moves 2 bytes back from the current position, which should do the same thing, although I haven't tested it, it compiles OK.

Amended on Sun 22 Jun 2003 11:44 PM by Nick Gammon
#18
That fixed it.

Thank you. =)
#19

Should anyone else have this problem, please contact me via email ( Darrik~swrip.net ). This is one of three bugs and a backdoor which I inform anyone who sends me an email ( as the license requests ).

Thank you,

Darrik Vequir
USA #20
Why not just post it here, if it's of general public interest?