1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. To chat with the GameOgre community, you need to have at least 100 posts. Once you have the 100 posts, post at Become A New Ogre
    Dismiss Notice

I need someone with basic C knowledge.

Discussion in 'Online Game Development' started by quinn, Jan 19, 2010.

Thread Status:
Not open for further replies.
  1. quinn

    quinn Starcatcher Ogre Veteran

    Messages:
    3,811
    Likes Received:
    386
    Trophy Points:
    83
    Credit:
    13,397.09
    I've ran into a error while editing my MUSH Source code, and really would like some help.

    Here is the code said error is yelling at:
    Code:
    FUNCTION(local_fun_c) 
    { 
      int times, c;
      int result = 0;
    
      if (!is_integer(fargs[1]) || (is_integer(fargs[1]) && parse_integer(fargs[1]) < 1)) { 
        times = 1; 
      } else { 
    	times = parse_integer(fargs[1]); 
      }
    
    	 while(times--) { 
    		 if(result) break; 
    
    		 if (is_integer(fargs[0]) && parse_integer(fargs[0]) > 0) { 
    				c = parse_integer(fargs[0]); 
    
    			   if (!((c == 1 || (c >= 3 && c <= 6) || (c >= 14 && c <= 254 && c != 27)))) { 
    				 result = 1; 
    					safe_str(T("No such FANSI character!"), buff, bufc); 
    			   } 
    			   else {
    					result = safe_chr(c, buff, bufc);
    			   }
    		   } 
    	 }
    }
    It's mad at the line "result = safe_chr(c,buff,bufc);"
    It is telling me that it is expecting an expression before the "{".

    So how am I supposed to fix this, so that it compiles correctly?
     
  2. awesomedrako

    awesomedrako Clubbed

    Messages:
    2,703
    Likes Received:
    463
    Trophy Points:
    0
    Credit:
    2,856.14
    You should be submitting this to a proper MUSH forum, not too many MUSH experts in this forum. Oh wait! There's one! His name is Qui...

    Damn.
     
  3. quinn

    quinn Starcatcher Ogre Veteran

    Messages:
    3,811
    Likes Received:
    386
    Trophy Points:
    83
    Credit:
    13,397.09
    This isn't MUSH, it's basic programming.
    In C.
    I thought I'd ask here first, since this is the programming/development section.

    (And there are no MUSH forums. It's been out for years, so those all have the last posts in 2006/7.)

    I wanna learn C anyway...maybe I'll try that 2! xD
     
  4. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    I have no knowledge and experience in C basic, but could you tell me the full and exact error that you get... plus it might help if you show more about the code, because now I can't tell where you reference the variables to...

    at first glance my guess is this is wrong:

    Code:
    result = safe_chr(c, buff, bufc);
    which I reckon (it's a very wild guess), should be:

    Code:
    result = (safe_chr(c, buff, bufc));
    but again I could be wrong
     
  5. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    oh wait you're saying that before this
    Code:
    else {
    is wrong

    ,because this bit

    Code:
    safe_str(T("No such FANSI character!"), buff, bufc);
    is not an expression

    example:

    Code:
    some_var = safe_str(T("No such FANSI character!"), buff, bufc);
    that is an expression


    keep in mind that i'm looking at it with a view of a scripter, not a programmer, so I could be terribly wrong about any of this
     
  6. quinn

    quinn Starcatcher Ogre Veteran

    Messages:
    3,811
    Likes Received:
    386
    Trophy Points:
    83
    Credit:
    13,397.09
    I'll try that...I didn't even write this code, I'm just attempting to put it in the MUSH. I'll get the error if it doesn't work.
     
  7. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    well I hope it works for you, else you're better off with awesomedrako's suggestion and register for some C basic forum, to see if they can help you out

    remember I just put down some variable
    the name is of course wrong, but I cannot tell you what it should be referenced to (what name it is), because it doesn't show in the piece of code you're posting here
     
  8. quinn

    quinn Starcatcher Ogre Veteran

    Messages:
    3,811
    Likes Received:
    386
    Trophy Points:
    83
    Credit:
    13,397.09
    Yeah I know that....I've had some basic knowledge of programming. :D

    Anyways, that didn't work, and other areas have the same format. I'm trying again to get the error right now.
     
  9. quinn

    quinn Starcatcher Ogre Veteran

    Messages:
    3,811
    Likes Received:
    386
    Trophy Points:
    83
    Credit:
    13,397.09
    Here's the error, removing your suggestion (which made more errors.):
    funmisc.c: In function ‘local_fun_c’:
    funmisc.c:1247: warning: passing argument 1 of ‘safe_copy_str’ makes pointer from integer without a cast ---Wasn't here before
    funmisc.c:1250: error: expected expression before ‘{’ token
    make[1]: *** [funmisc.o] Error 1
    make[1]: Leaving directory `/home/quinn/Documents/tinymush-3.1p6/src'
    make: *** [build] Error 2

    Line 1250 is the line that you were talking about.
     
  10. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    OK well I hope you figure it out eventually

    if at first you don't succeed, then try and try again...
     
  11. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    ok so
    else { is line 1250 right?

    that's a missreference that much I can figure out

    I've got dinner right now, so I'll look at it again later
     
  12. quinn

    quinn Starcatcher Ogre Veteran

    Messages:
    3,811
    Likes Received:
    386
    Trophy Points:
    83
    Credit:
    13,397.09
    That wasn't there before.

    1250 is after the else { line...
     
  13. shugo

    shugo Elite Ogre Ogre Veteran

    Messages:
    2,093
    Likes Received:
    12
    Trophy Points:
    38
    Credit:
    15,378.42
    ok so this is line 1250
    and this line 1249
    1248
    1247
    error: makes pointer from integer without a cast you get this new one, because now you're making an expression, which I reckon is the right the way... but because the reference is wrong it is pointing to nothing, hence integer without cast

    in php it then returns false, don't know what it does in C basic (like I said, no experience)
    assuming it doesn't do that in C basic, but instead makes it as a no expression, because it isn't valid (because the variable is phony), hence you'd still get the error at 1250

    my guess is that you supposed to make an expression, where no expression exist, which is line 1247... find out the right name of the variable and it should work just fine without any further errors in function local_fun_c


    but again i'm not sure... and this is as good a suggestion i can give you... don't see atm what else could be it

    I'm looking further back atm at the condition to see what else could be the matter
    If NOT (( c is 1 or (c is larger than 2 and smaller than 7) or (c is larger than 13 and smaller than 255 and c is not 27) ))

    and i'm not even seeing why that should be double (( )) must be a quirck of C basic or something, wish i could be of more help, but my knowledge of c basic is too limited to be of any further assistance
     
Thread Status:
Not open for further replies.

Share This Page