Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, DotBot, Yandex

Members: 0
Guests: 5
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Gboards help - Solved
Forum Rules | Mark all | Recent Posts

Gboards help - Solved
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
* #1 Dec 14, 2010, 10:06 am
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Okay...I admit I'm the noobest coder ever, so please accept that and be prepared to see me in the future. ;)

So, what I'm looking to do is make one of the boards exempt from the auto-delete that seems to happen after x amount of days. If I knew where to look, it wouldn't be an issue, but I don't. I checked boards.c and can't seem to find where the time limit is set, if it's even set here. Any direction/help would be appreciated!

Cheers,
Aurin
       
Post is unread #2 Dec 14, 2010, 4:57 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

Check out gboard.c line 380. I'm fairly sure that is the part your wanting to take a look at.
       
Post is unread #3 Dec 15, 2010, 7:27 pm   Last edited Dec 16, 2010, 12:51 am by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

heh...thanks Remcon...I was looking through the files and completely missed gboards.c...saw boards.c and was hoping that was it, but didn't see anything in there for it. And I see what you're talking about...now to see if i can specify the board I want.

okay, I think I got it:
	
if(board->short_name == "Stories")
  return;


If I'm right, this should accomplish my goal, placed just above where the notes are purged. Won't know for a day, as I had no way to test it immediately, but it compiled fine on my test server, so here's hoping. heh
       
Post is unread #4 Dec 16, 2010, 3:12 pm   Last edited Dec 16, 2010, 3:57 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

okay, so...the location I placed it caused the Stories board to not even load.. :whistle: :facepalm:

on the bright side, I at least confirmed the right variable I needed to get excluded..maybe... heh
       
Post is unread #5 Dec 16, 2010, 3:59 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

I would use like
if( !str_cmp( board->short_name, "Stories" ) )
   return;

Only I think your not doing it just right, Post that whole function so I can look at it without having to log in and look at it lol.
       
Post is unread #6 Dec 16, 2010, 4:07 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

/* Load a single board */
void load_board(GLOBAL_BOARD_DATA * board)
{
  FILE                   *fp;
  NOTE_DATA              *last2_note;
  char                    filename[200];
  bool                    resave = FALSE;

  snprintf(filename, 200, "%s%s", NOTE_DIR, board->short_name);
  fp = FileOpen(filename, "r");
  /*
   * Silently return 
   */
  if(!fp)
    return;
  /*
   * Start note fetching. copy of db.c:load_notes() 
   */
  last2_note = NULL;
  for(;;)
  {
    NOTE_DATA              *pnote;
    char                    letter;

    do
    {
      letter = getc(fp);
      if(feof(fp))
      {
        FileClose(fp);
        fp = NULL;
        if(resave)
          save_board(board);
        return;
      }
    }
    while(isspace(letter));
    ungetc(letter, fp);
    CREATE(pnote, NOTE_DATA, sizeof(*pnote));

    if(str_cmp(fread_word(fp), "sender"))
      break;
    pnote->sender = fread_string(fp);
    if(str_cmp(fread_word(fp), "date"))
      break;
    pnote->date = fread_string(fp);
    if(str_cmp(fread_word(fp), "stamp"))
      break;
    pnote->date_stamp = fread_number(fp);
    if(str_cmp(fread_word(fp), "expire"))
      break;
    pnote->expire = fread_number(fp);
    if(str_cmp(fread_word(fp), "to"))
      break;
    pnote->to_list = fread_string(fp);
    if(str_cmp(fread_word(fp), "subject"))
      break;
    pnote->subject = fread_string(fp);
    if(str_cmp(fread_word(fp), "text"))
      break;
    pnote->text = fread_string(fp);
    if(!str_cmp(fread_word(fp), "voting"))
    {
      pnote->voting = fread_number(fp);
      if(str_cmp(fread_word(fp), "yesvotes"))
        break;
      pnote->yesvotes = fread_string(fp);
      if(str_cmp(fread_word(fp), "novotes"))
        break;
      pnote->novotes = fread_string(fp);
      if(str_cmp(fread_word(fp), "abstentions"))
        break;
      pnote->abstentions = fread_string(fp);
    }
    pnote->next = NULL; /* jic */

    /*
     * Should this note be archived right now ? 
     */
	
   if(pnote->expire < current_time)
    {
// Here's my addition
	if(board->short_name == "Stories" )
	{
	  free_global_note(pnote);
	  resave = TRUE;
	  continue;
	}
// End of my addition
      free_global_note(pnote);
      resave = TRUE;
      continue;
    }
	
    if(board->note_first == NULL)
      board->note_first = pnote;
    else
      last2_note->next = pnote;
    last2_note = pnote;
  }
  bug("%s", "Load_notes: bad key word.");
}


This gets the board to load with notes, but I won't know if the note keeps past the expiration point until that point comes. heh
       
Post is unread #7 Dec 16, 2010, 4:20 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

change this
   if(pnote->expire < current_time)
    {
// Here's my addition
	if(board->short_name == "Stories" )
	{
	  free_global_note(pnote);
	  resave = TRUE;
	  continue;
	}
// End of my addition
      free_global_note(pnote);
      resave = TRUE;
      continue;
    }

to this
   if( pnote->expire < current_time && str_cmp( board->short_name, "Stories" ) )
    {
      free_global_note(pnote);
      resave = TRUE;
      continue;
    }

That should make it work as you want.
       
Post is unread #8 Dec 16, 2010, 4:26 pm   Last edited Dec 16, 2010, 4:26 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Remcon said:


   if( pnote->expire < current_time && str_cmp( board->short_name, "Stories" ) )
    {
      free_global_note(pnote);
      resave = TRUE;
      continue;
    }



Err...wouldn't that exclude the saving of all other notes except those from the Stories board?

Possibly something like this?
   if( pnote->expire < current_time || (pnote->expire < current_time && str_cmp( board->short_name, "Stories" ) ) )
    {
      free_global_note(pnote);
      resave = TRUE;
      continue;
    }
       
Post is unread #9 Dec 16, 2010, 4:32 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

Nope, the way I put it should be correct. You don't want it to remove the notes on the Stories board correct? and it doesn't need to resave them unless it removes a note from the board.

if( pnote->expire < current_time

Naturally that is to check and see if it has expired and if so then do
str_cmp( board->short_name, "Stories" ) )

If the board short name isn't Stories then it will remove the note and set it to resave the board.
       
Post is unread #10 Dec 16, 2010, 4:53 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Okay, I know you know what you're talking about, but it's difficult for me to learn if I don't understand the concept, and I seem to misunderstand something here..so..:
if(pnote->expire < current_time && str_cmp(board->short_name, "Stories"))

Okay, the expire is supposed to be greater than the current_time for it to save, I get that. ..so, if expire > current_time this part of the check is FALSE (and on the original code would not save the note, which is what is supposed to happen)...on the other side of the "&&" we check to make sure it's of the Stories board (because I want the new addition to save, regardless of whether it's expired or not). if it is, this side of the "&&" is TRUE. FALSE and TRUE in an AND statement = FALSE, thus the ifcheck doesn't trigger and the note is not saved. That said, it shouldn't save any other boards as the second part of the check will always be FALSE unless it is Stories.

       
Post is unread #11 Dec 16, 2010, 8:08 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005


Okay, the expire is supposed to be greater than the current_time for it to save, I get that. ..so, if expire > current_time this part of the check is FALSE (and on the original code would not save the note, which is what is supposed to happen)...on the other side of the "&&" we check to make sure it's of the Stories board (because I want the new addition to save, regardless of whether it's expired or not). if it is, this side of the "&&" is TRUE. FALSE and TRUE in an AND statement = FALSE, thus the ifcheck doesn't trigger and the note is not saved. That said, it shouldn't save any other boards as the second part of the check will always be FALSE unless it is Stories.

I think your misunderstanding what happens in it as a whole
   if( pnote->expire < current_time && str_cmp( board->short_name, "Stories" ) )
    {
      free_global_note(pnote);
      resave = TRUE;
      continue;
    }

First line if pnote->expire is less then current_time and the board isn't got a short name of Stories
Both of those being true it will go in and free the note it just loaded (another words this board isn't stories and the note has expired).
If the note hasn't expired or the board is the stories board it will add the note to the list of notes for the board and continue.

The resave is only done if a note is removed from the board other wise the note is kept and no reason to resave the board.
       
Post is unread #12 Dec 16, 2010, 8:36 pm   Last edited Dec 16, 2010, 8:44 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Remcon said:


First line if pnote->expire is less then current_time and the board isn't got a short name of Stories
Both of those being true it will go in and free the note it just loaded (another words this board isn't stories and the note has expired).
If the note hasn't expired or the board is the stories board it will add the note to the list of notes for the board and continue.

The resave is only done if a note is removed from the board other wise the note is kept and no reason to resave the board.


Alright...I think I get it...but wouldn't we want it to read:
 !str_cmp( board->short_name, "Stories" ) ) 

This way, it's looking for NOT short_name Stories? This would exclude short_name "Stories" from being freed, instead of including it.

And, to try and show that I understand with your suggested change...
We have pnote->expire time of 1 with current_time of 2 (for simplicities sake). pnote->expire < current_time = TRUE
We have a string comparison of board->short_name and "Stories" and the pnote is from the "Stories" board .... board->short_name = TRUE
With both TRUE, we execute the check:
note freed
board resaved
We no longer have a note from the "Stories" board if it expires.

Did I get through that correctly? heh

For some idiotic notion, I was under the assumption this is where the note was being saved, not freed. *LOL* Thanks for spelling it out to me.
       
Post is unread #13 Dec 16, 2010, 9:21 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Not exactly, in this case you want str_cmp to return true and skip that, and if it's false remove the notes.
       
Post is unread #14 Dec 16, 2010, 9:41 pm   Last edited Dec 16, 2010, 9:54 pm by Aurin
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Kayle said:

Not exactly, in this case you want str_cmp to return true and skip that, and if it's false remove the notes.

okay, so it seems a lot of my misunderstanding is coming from str_cmp.
let me setup another simplistic example exclusively for this function:
board->short_name = "Stories"
if( str_cmp( board->short, "Stories" )
  send_to_char("Since this is TRUE, the check fired and this note is from board Stories.\r\n", ch);

This is my thought process when I think of this function.
       
Post is unread #15 Dec 17, 2010, 11:48 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,857
JoinedJul 26, 2005

board->short_name = "Stories"
//if( str_cmp( board->short, "Stories" )
if( !str_cmp( board->short, "Stories" )
  send_to_char("Since this is TRUE, the check fired and this note is from board Stories.\r\n", ch);

If you did str_cmp( board->short, "Stories" ) and board->short_name is stories it wouldn't fire.
if( !str_cmp( "Test", "Test" ) )
   send_to_char( "These strings are the same.\r\n", ch );
if( str_cmp( "Test", "Test2" ) )
   send_to_char( "These strings are not the same.\r\n", ch );

if( str_cmp( "Test", "Test" ) )
   send_to_char( "These strings are not the same.\r\n", ch ); /* Wouldn't see this since they are the same */
else
   send_to_char( "These strings are the same.\r\n", ch ); /* Would always see this one since the strings are the same */

if( !str_cmp( "Test", "Test2" ) )
   send_to_char( "These strings are the same.\r\n", ch ); /* Wouldn't see this since they are not the same */
else
   send_to_char( "These strings are not the same.\r\n", ch ); /* Would always see this one since the strings are not the same */

Hope this clears it up a bit for you.
       
Post is unread #16 Dec 17, 2010, 1:56 pm
Go to the top of the page
Go to the bottom of the page

Aurin
Magician
GroupMembers
Posts189
JoinedSep 5, 2010

Hope this clears it up a bit for you.


Yup, explains things better for me, thanks! heh

As for the testing of what I'm trying to do, so far so good..won't know 'til later tonight if it works like I want or not. :P
       
Pages:<< prev 1 next >>