Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ ROM ➜ Running the server ➜ RT ASCII stuff...

RT ASCII stuff...

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #15 on Sun 30 May 2004 04:10 AM (UTC)
Message
What is a 'logic programmer' as opposed to a 'normal programmer'? What language did you program in?

Do you understand what this is doing:

 for ( offset = 0, cp = buf; offset < 64; offset++ )
if ( flags & ( (long)1 << offset ) )
{
if ( offset <= 'Z' - 'A' )
*(cp++) = 'A' + offset;
else
*(cp++) = 'a' + offset - ( 'Z' - 'A' + 1 );
}

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nash   USA  (20 posts)  Bio
Date Reply #16 on Sun 30 May 2004 04:39 AM (UTC)

Amended on Sun 30 May 2004 04:48 AM (UTC) by Nash

Message
It means I suck with math, I'm better with more graphics type games, as opposed to thinking of the world in math functions, it's weird checks and word functions. I used to code vb and javascript, and the little c and j I did for a month, the former of which I'm trying to relearn! The function you point out writes letters to the designated file, which correspond to the different flags of a mob, apparently going based on the ascii of the upper/lower case letters... I don't understand totally how it works, but I know what it does.. it'd be more effective probably to write down 64 0's and then for each of those flags that's active, change its corresponding 0 to a 1, and then have it read in that way as well.. unless I have how it works wrong!
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #17 on Sun 30 May 2004 05:13 AM (UTC)
Message
With all due respect you can't cover C or Java in just a month if you've never done real programming before.

What that function is doing is writing out the letter constants that were given to the decimal constants. For instance, if the offset is zero, it will write A. If the offset is three, it will write D. If the offset is 26, it will write 'a'.

What this means is that you have an upper limit of 52=26*2 possible flags. If the system were more a little more intelligent, it wouldn't have such an upper limit.

You could write out the binary representation of the flag. That would be 64 characters, however. It would take up less memory to write out the decimal version. Only problem is that manipulating 64-bit numbers is harder than 32-bit numbers.

One problem is that you cast the bitshift to long and not long long. This won't work at all if your bitshift goes out of long range, which is clearly does since offset goes to 64.

Allow me to warn you again: what you are attempting to do is non-trivial and you seem to be a novice coder. I strongly suggest that you look at SMAUG's EXT_BV code. Have you done that yet?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nash   USA  (20 posts)  Bio
Date Reply #18 on Sun 30 May 2004 05:53 AM (UTC)
Message
altered that for loop, trying to make it work a bit better, and it sorta prints it in binary.. but it ends up looking like this!

#818
no name~
(no short description)~
(no long description)
~
~
human~
1111111111111111111111111111111111 0 0 0
0 0 0d0+0 0d0+0 0d0+0 none
0 0 0 0
0 0 0 0
stand stand none 0
0 0 medium unknown
F for 1111
F par 11111111111
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #19 on Sun 30 May 2004 06:09 AM (UTC)
Message
How am I supposed to know if that output is correct or not? Besides, if it's wrong, there's only one reason: you must have made a mistake in your output code.

Forgive me for copy/pasting, but... Allow me to warn you again: what you are attempting to do is non-trivial and you seem to be a novice coder. I strongly suggest that you look at SMAUG's EXT_BV code. Have you done that yet?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nash   USA  (20 posts)  Bio
Date Reply #20 on Sun 30 May 2004 06:16 AM (UTC)

Amended on Sun 30 May 2004 06:23 AM (UTC) by Nash

Message
I have... smaug uses a structure to store flags, and reads/loads them all differently... I can paste in the functions.. but I'd have to know which you need to see ...I'm trying really hard to learn this and figure out the workings of it all, but it's quite hard to learn c on your own, thank ya for this.. but... yea smaug does it weird. So, in fwrite_flag, it should write out a 0 for each inactive flag, and a 1 for each active one, and then in fread_flag, do the reverse?

new fwrite_flag?->
for ( offset = 0, cp = buf; offset < 64; offset++ )
if ( flags & ( (long long)1 << offset ) )
{
*(cp++) = '1';
}
else
{
*(cp++) = '0';
}
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #21 on Sun 30 May 2004 06:40 AM (UTC)
Message
What you should do is do as SMAUG does in order to read and write flags. Imitate what they have. SMAUG doesn't do it "weird", chances are, they do it "right". :)

Very seriously, you should learn C before you do something non-trivial like this. Your function looks like it's right, but chances are you're forgetting something somewhere else. What is the type of 'flags'?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nash   USA  (20 posts)  Bio
Date Reply #22 on Sun 30 May 2004 07:21 AM (UTC)

Amended on Sun 30 May 2004 09:43 AM (UTC) by Nash

Message
actually.. somehow it works now, but... I get this:

In file included from /usr/include/bits/sigcontext.h:28,
from /usr/include/signal.h:313,
from comm.c:92:
/usr/include/asm/sigcontext.h:76: syntax error before numeric constant
/usr/include/asm/sigcontext.h:80: syntax error before '}' token


:(
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


50,374 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.