19 Jan, 2010, Crelin wrote in the 1st comment:
Votes: 0
I notice this set of BUG strings in my logfile everytime someone asaves (haven't narrowed it down to asave changed or asave world, where the save_clans function is used)…here's the set of bugs (note, I modified the string it outputs myself to state with it sees as the astring and bstring to originally help in debugging this).
Sat Jan 16 23:20:13 2010 :: [*****] BUG: Strn_cmp: null astr.
Sat Jan 16 23:20:13 2010 :: [*****] BUG: astr null a:(null) b:
Sat Jan 16 23:20:13 2010 :: [*****] BUG: Strn_cmp: null astr.
Sat Jan 16 23:20:13 2010 :: [*****] BUG: astr null a:(null) b:Immortals
Sat Jan 16 23:20:13 2010 :: [*****] BUG: Strn_cmp: null astr.
Sat Jan 16 23:20:13 2010 :: [*****] BUG: astr null a:(null) b:Brotherhood of Whispers
Sat Jan 16 23:20:13 2010 :: [*****] BUG: Strn_cmp: null astr.
Sat Jan 16 23:20:13 2010 :: [*****] BUG: astr null a:(null) b:Arcane Council
Sat Jan 16 23:20:13 2010 :: [*****] BUG: Strn_cmp: null astr.
Sat Jan 16 23:20:13 2010 :: [*****] BUG: astr null a:(null) b:Druidic Circle
Sat Jan 16 23:20:13 2010 :: [*****] BUG: Strn_cmp: null astr.
Sat Jan 16 23:20:13 2010 :: [*****] BUG: astr null a:(null) b:Hell's Winter


and here is the save_clans function…
void save_clans(CHAR_DATA *ch, char *argument)
{
FILE *fp;
int i;
int value;
char buf[MSL];

sprintf (buf, "%sguild.dat", DATA_DIR);
if ( !( fp = fopen(buf, "w" ) ) )
{
bug("Open_guild: fopen", 0 );
return;
}

for (i = 1; clan_lookup(clan_table[i].name) != 0; i++)
{
if ( !IS_SET(clan_table[i].flags, CLAN_DELETED)
&& clan_lookup(clan_table[i].name) != 0)
{
fprintf(fp, "\nClan\t%s~\n", clan_table[i].name);

fprintf(fp, "Who\t%s~\n", clan_table[i].who_name);

fprintf(fp, "Leader\t%s~\n", clan_table[i].leader);

for (value = 1; value < MAX_RANK; value++)
{
if (clan_table[i].c_rank[value].rankname == NULL
|| clan_table[i].c_rank[value].rankname[0] == '\0')
clan_table[i].c_rank[value].rankname = str_dup("Unassigned");

fprintf(fp, "Rank\t%d\t%s~\n",
value, clan_table[i].c_rank[value].rankname);
}

/* Remove "changed" bit before writing flags to file */
if (IS_SET(clan_table[i].flags, CLAN_CHANGED))
REMOVE_BIT(clan_table[i].flags, CLAN_CHANGED);

fprintf( fp, "Flags %s\n", fwrite_flag( clan_table[i].flags, buf ) );
fprintf(fp, "\n");
}
}

fprintf(fp, "\nEnd\n");
fclose(fp);
return;
}


Setup: Rom2.4b6 with patched in lopes and ivans olc 1.81 I believe (the most stable one),
anyone have any help? can provide further code if needed.

here is also the clan_lookup code used
int clan_lookup(const char *name)
{
int clan;

for (clan = 0; clan < (1 + top_clan); clan++)
{
if (!str_prefix(name, clan_table[clan].name))
return clan;
}

return 0;
}


and the clan_type structure used
struct clan_type
{
long flags; /* flags for clan */
char *name; /* name of clan */
char *who_name; /* name sent for "who" command */
char *leader; /* leader of clan */
rankdata c_rank[MAX_RANK]; /* clans rank system */
char *exname;
bool pkill;
bool independent;
};


I'm befuddled personally.
19 Jan, 2010, David Haley wrote in the 2nd comment:
Votes: 0
for (i = 1; clan_lookup(clan_table[i].name) != 0; i++)

This is probably your problem; it's a somewhat bizarre termination condition. It's basically saying: stop the for loop when we try to look up a clan's name, and get 0 back. But how is that last clan set up? Maybe its name is NULL – which would explain the NULL warnings as it tries to compare stuff in clan_lookup.

The short term solution is for clan_lookup to return 0 if name == NULL, but you might also want to find a better way of looping over available clans. For example, you probably know the number of clans somewhere, as a value based off of the size of clan_table – why not loop using that as your boundary?
19 Jan, 2010, Crelin wrote in the 3rd comment:
Votes: 0
Well the clans are written to and read from a guild.dat file since I use cedit and there is no NULL clan in it, just the clans and an ending terminator…so for now I guess I'll modify the loop with how many I clans I know they're are and an added MAX_CLAN variable until I set cedit and the mod to properly increase/decrease the variable itslef.

This should work I'm assuming?
19 Jan, 2010, David Haley wrote in the 4th comment:
Votes: 0
The ideal solution would be to track the number of clans you have read as you read them from the file in the first place. I'm not sure what you have in mind for the cedit approach; am I misunderstanding something?
19 Jan, 2010, Crelin wrote in the 5th comment:
Votes: 0
no, you're not…what I meant in a chopped up way is to have the global max_clan variable set to how many clans are read from the file
but until then just set max_clan manually to how many clans I know I have and modify the loop to represent max_clan instead of checking for if the clans name equals 0. Thank you very much for the help, the temp fix is in and working and will work on the permanent fix here soon when I get into modifying the clan system further.
19 Jan, 2010, David Haley wrote in the 6th comment:
Votes: 0
Oh, ok. That seems like a reasonable approach. Glad that you got it worked out. :smile:
21 Jan, 2010, Crelin wrote in the 7th comment:
Votes: 0
haha, I somehow missed entirely that top_clan already counted the clans so a simple
for (i = 0; i < (1 + top_clan); i++)

in liue of the old one that checked for the clans name worked just fine for a perm fix. Ran into a small bug that made cedit create crash the mud, but I figured out it was just a corrupt guild.dat file from some previous misedits to save_clans - all is good. :D
0.0/7