14 Mar, 2009, boblinski wrote in the 1st comment:
Votes: 0
Alright, I'm trying to add the Camo skill and the Focus skill.
Camo is basically hide, but will only work out of towns. and Focus is basically 'Detect Invis' except it's a skill not a spell.

This is the error I'm getting:
Quote
gcc -Wall -O -ggdb -DNOCRYPT -DQMFIXES -c -o obj/act_info.o act_info.c
act_info.c: In function `do_focus':
act_info.c:3122: error: `ff' undeclared (first use in this function)
act_info.c:3122: error: (Each undeclared identifier is reported only once
act_info.c:3122: error: for each function it appears in.)
make: *** [obj/act_info.o] Error 1


This is the do_focus part of act_info.c:
void do_focus (CHAR_DATA * ch, char *argument)
{
AFFECT_DATA af;

/*3122*/ if (IS_AFFECTED (ch, AFF_FOCUS))
{
return;
}

if (number_percent () < get_skill (ch, gsn_focus))
{
check_improve (ch, gsn_focus, TRUE, 3);
af.where = TO_AFFECTS;
af.type = gsn_focus;
af.level = ch->level;
af.duration = ch->level;
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_FOCUS;
affect_to_char (ch, &af);
send_to_char ("You focus on your surroundings.\n\r", ch);
}
else
{
check_improve (ch, gsn_focus, FALSE, 3);
send_to_char ("You cannot seem to focus on your surroundings.\n\r", ch);
affect_strip (ch, gsn_focus);
}

return;
}


And this is the only part in my code where I have "(ff)" (in merc.h):
#define AFF_FOCUS     (ff)
14 Mar, 2009, David Haley wrote in the 2nd comment:
Votes: 0
Quote
#define AFF_FOCUS (ff)

What is this supposed to be doing?
14 Mar, 2009, boblinski wrote in the 3rd comment:
Votes: 0
Ummm, I thought I was meant to add it in merc.h… all the other skills are defined in their under

/*
* Bits for 'affected_by'.
* Used in #MOBILES.
*/
#define AFF_BLIND (A)
#define AFF_INVISIBLE (B)
#define AFF_DETECT_EVIL (C)
#define AFF_DETECT_INVIS (D)
#define AFF_DETECT_MAGIC (E)
#define AFF_DETECT_HIDDEN (F)
#define AFF_DETECT_GOOD (G)
#define AFF_SANCTUARY (H)
#define AFF_FAERIE_FIRE (I)
#define AFF_INFRARED (J)
#define AFF_CURSE (K)
#define AFF_UNUSED_FLAG (L) /* unused */
#define AFF_POISON (M)
#define AFF_PROTECT_EVIL (N)
#define AFF_PROTECT_GOOD (O)
#define AFF_SNEAK (P)
#define AFF_HIDE (Q)
#define AFF_SLEEP (R)
#define AFF_CHARM (S)
#define AFF_FLYING (T)
#define AFF_PASS_DOOR (U)
#define AFF_HASTE (V)
#define AFF_CALM (W)
#define AFF_PLAGUE (X)
#define AFF_WEAKEN (Y)
#define AFF_DARK_VISION (Z)
#define AFF_BERSERK (aa)
#define AFF_SWIM (bb)
#define AFF_REGENERATION (cc)
#define AFF_SLOW (dd)
#define AFF_CAMO (ee)
#define AFF_FOCUS (ff)
14 Mar, 2009, boblinski wrote in the 4th comment:
Votes: 0
Also, if I comment out that line in merc.h I still get this warning:
Quote
gcc -Wall -O -ggdb -DNOCRYPT -DQMFIXES -c -o obj/act_info.o act_info.c
act_info.c: In function `do_focus':
act_info.c:3122: error: `AFF_FOCUS' undeclared (first use in this function)
act_info.c:3122: error: (Each undeclared identifier is reported only once
act_info.c:3122: error: for each function it appears in.)
make: *** [obj/act_info.o] Error 1
14 Mar, 2009, tphegley wrote in the 5th comment:
Votes: 0
You have to define the ff right above that section of the AFF_*'s. Just double that last number I believe.

#
#define aa 67108864 /* doubled due to conflicts */
#
#define bb 134217728
#
#define cc 268435456
#
#define dd 536870912
#
#define ee 1073741824
#
#define ff 2147483648

#
/*
#
* ACT bits for mobs.
#
* Used in #MOBILES.
#
*/
#
#define ACT_IS_NPC (A) /* Auto set for mobs */
#
#define ACT_SENTINEL (B) /* Stays in one room */
#
#define ACT_SCAVENGER (C) /* Picks up objects */
#
#define ACT_AGGRESSIVE (F) /* Attacks PC's */
14 Mar, 2009, elanthis wrote in the 6th comment:
Votes: 0
You probably need to define ff somewhere, I guess. What is happening is pretty simple. AFF_FOCUS is replaced by (ff). So that line of code you put AFF_FOCUS is equivalent to typing:

af.bitvector = (ff);


You have to tell the compiler what the heck ff is supposed to mean, though. Somewhere in a header that has #define or const definitions for all those letter identifiers. Find it and add ff. You might have luck finding it by using a command like:

grep '\<ee\>' src/*.c

(Obviously replace src/ with the path to your source directory if it differs.)

edit: Ninja'd! :)
14 Mar, 2009, Sandi wrote in the 7th comment:
Votes: 0
Are you running stock ROM on a 32 bit machine?
15 Mar, 2009, Skol wrote in the 8th comment:
Votes: 0
bob, you might also want to do the 'act2' addition to Rom. It allows you to do another set of bits. (A-Z, aa-ee etc). Could conceivably do act3, act4 etc, although in that case a different system might work better hehe.

You can find the act2 snip: http://www.mudbytes.net/index.php?a=file...

Or click on Code Repository/Diku/Merc/Rom/Snippets/Flags & Bits/ and it's the top one.
15 Mar, 2009, Keberus wrote in the 9th comment:
Votes: 0
Skol said:
bob, you might also want to do the 'act2' addition to Rom. It allows you to do another set of bits. (A-Z, aa-ee etc). Could conceivably do act3, act4 etc, although in that case a different system might work better hehe.

You can find the act2 snip: http://www.mudbytes.net/index.php?a=file...

Or click on Code Repository/Diku/Merc/Rom/Snippets/Flags & Bits/ and it's the top one.


Or you could always switch to extended bitvectors which would allow you to scale probably as high as needed, without having to have multiple act#'s. Just a thought though.

Later,
KeB
15 Mar, 2009, boblinski wrote in the 10th comment:
Votes: 0
Sandi said:
Are you running stock ROM on a 32 bit machine?

I'm running Windows XP using Cygwin.
15 Mar, 2009, boblinski wrote in the 11th comment:
Votes: 0
Why would adding Act2 help? What is it and what does it do? Would it stop this:

Quote
gcc -Wall -O -ggdb -DNOCRYPT -DQMFIXES -c -o obj/act_info.o act_info.c
act_info.c: In function `do_focus':
act_info.c:3122: warning: this decimal constant is unsigned only in ISO C90
act_info.c:3136: warning: this decimal constant is unsigned only in ISO C90


Also, what did Keberus mean by "switch to extended bitvectors" ?
15 Mar, 2009, Skol wrote in the 12th comment:
Votes: 0
Er, actually do the affect 2 one. Same idea though, ch->affect2. It just gives you another set to do without having to bust up ff/gg/etc into the big nasty numbers heh.

You might wait on extended bits though bob, it's a healthy endeavor for a newer coder. What it does is extend the bits to longs I believe? In plain English, you run out of room with a short int (max size), with the longs it's in the brazilians (past boojillians, and bajillions heh), vs like 32k. There's a few threads here about it but I don't have the links offhand.
15 Mar, 2009, Kline wrote in the 13th comment:
Votes: 0
My solution was use g++ and implement std::bitset. EXT_BV was just too much of a hack when there was something already provided for me :)
15 Mar, 2009, Keberus wrote in the 14th comment:
Votes: 0
Kline said:
My solution was use g++ and implement std::bitset. EXT_BV was just too much of a hack when there was something already provided for me :)


Right, but if he can't compile with g++ then he won't be doing that method. It looks like with the EXT_BV implementation that I am using, you can have up to 128 'flags'/BVs or whatever you want to call them. Which should be more than enough for any given thing. Also, I didn't find it all that difficult to implement them, but eh, whatever's clever.

Later
15 Mar, 2009, boblinski wrote in the 15th comment:
Votes: 0
Keberus said:
It looks like with the EXT_BV implementation that I am using, you can have up to 128 'flags'/BVs or whatever you want to call them. Which should be more than enough for any given thing. Also, I didn't find it all that difficult to implement them, but eh, whatever's clever.


Could anyone please step me through this?
15 Mar, 2009, Kayle wrote in the 16th comment:
Votes: 0
EXT_BVs isn't something anyone here could "step you through" so to speak. It's generally a very tedious and complicated conversion which is going to take a moderate understanding of programming and how bitwise math works to get it done. Although, there might be a snippet in the ROM directory that goes over adding extended bitvectors to ROM. BUt I'm with Kline. std::bitset and C++ is a helluva lot easier to use, and is limitless for all intents and purposes of a MUD environment.
15 Mar, 2009, boblinski wrote in the 17th comment:
Votes: 0
I'm only just learning to code in C let alone C++… so what is the easiest way for me to fix this:

Quote
act_info.c:3122: warning: this decimal constant is unsigned only in ISO C90
15 Mar, 2009, Keberus wrote in the 18th comment:
Votes: 0
boblinski said:
I'm only just learning to code in C let alone C++… so what is the easiest way for me to fix this:

Quote
act_info.c:3122: warning: this decimal constant is unsigned only in ISO C90


That doesn't tell much, can you show us the line of code it's referencing.
15 Mar, 2009, boblinski wrote in the 19th comment:
Votes: 0
void do_focus (CHAR_DATA * ch, char *argument)
{
AFFECT_DATA af;

if (IS_AFFECTED (ch, AFF_FOCUS)) /* line 3122 */
{
return;
}

if (number_percent () < get_skill (ch, gsn_focus))
{
check_improve (ch, gsn_focus, TRUE, 3);
af.where = TO_AFFECTS;
af.type = gsn_focus;
af.level = ch->level;
af.duration = ch->level;
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_FOCUS;
affect_to_char (ch, &af);
send_to_char ("You focus on your surroundings.\n\r", ch);
}
else
{
check_improve (ch, gsn_focus, FALSE, 3);
send_to_char ("You cannot seem to focus on your surroundings.\n\r", ch);
affect_strip (ch, gsn_focus);
}

return;
}


I think it all leads back to the problem of
Quote
#define ff 2147483648

and
Quote
#define AFF_FOCUS (ff)
15 Mar, 2009, Kline wrote in the 20th comment:
Votes: 0
If you're on a 32-bit machine (probably) you can't have anything larger than 31 defined values…So your A, B, C, D … ee, ff, etc … You can only have up to 31 of before the numbers (they double each time) get too large for the system to handle. Make sure that's not the case.
0.0/45