Patch Command

  • Liko
  • Liko's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
4 years 6 months ago #4870 by Liko
Patch Command was created by Liko
Hello,

I've added a new snippet( Patch Command). What is this snippet do? The patch snippet allows immortals to post what they have recently changed to the news file. I wanted to give the news file more use. It is changelog with more use and just a few other things. This reboots the news file.

Usage: patch <what changed>

Example: patch Warriors whirlwind damaged has been reduced by half.

Hp: 10 Mp: 10 mv: 10 (news)<--will show up again if gone)

Now it does use your current NEWS file. So you must be willing to get rid of it.

Sincerely,

Liko.

DragonBall: Tournament (1.2.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

  • Liko
  • Liko's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
4 years 6 months ago #4873 by Liko
Replied by Liko on topic Patch Command
Can I have this moved to the snippets area.

DragonBall: Tournament (1.2.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
4 years 6 months ago #4875 by Rumble
Replied by Rumble on topic Patch Command

Rumble
The Builder Academy
tbamud.com 9091

Please Log in or Create an account to join the conversation.

  • Liko
  • Liko's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
4 years 6 months ago #4876 by Liko
Replied by Liko on topic Patch Command

Rumble wrote: Done.


I meant the board. I had them in the snippets on the download page. Oops :).

DragonBall: Tournament (1.2.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #5164 by dracmas
Replied by dracmas on topic Patch Command
I thought this a nice feature to use, but can't see the snippet for it. Looks like it was removed or not accessed when the boards were updated.

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #5168 by Rumble
Replied by Rumble on topic Patch Command
Yes, we no longer have a downloads section. You can cut and paste the text here using the code tag or you can submit it via github.

Rumble
The Builder Academy
tbamud.com 9091

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #5170 by dracmas
Replied by dracmas on topic Patch Command
It's not my snippet but Liko's. I wanted to look at it, but since the link doesn't work anymore, I was hoping there was another way to it.

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #5172 by Rumble
Replied by Rumble on topic Patch Command
Found it. Anyone have a recommendation for hosting all of our downloads? Every time I pick a solution it goes under in a year or two and is no longer supported. I'm thinking maybe just Google drive. Thoughts?
V1.00

Hello!  Welcome to my patch command.   This combines the current news and changelog command and takes them to a better system.  

First off,  the patch commad just allows you to type what you just type.  patch Warriors damage Whirlwind damage has been reduced.  Now where will that appear?  That will now show up in the News file.  The players (news) icon will now show up in their prompt showing a new update.    Now lets get this patch underway:

1).  Open act.wizard.c and go to the end of the file:

ACMD(do_patch)
{
  time_t rawtime;
  char tmstr[MAX_INPUT_LENGTH], line[READ_SIZE], last_buf[READ_SIZE],
      buf[READ_SIZE];
  FILE *fl, *new;

  skip_spaces(&argument);

  if (!*argument) {
    send_to_char(ch, "Usage: patch <change>\r\n");
    return;
  }

  sprintf(buf, "%s.bak", NEWS_FILE);
  if (rename(NEWS_FILE, buf)) {
    mudlog(BRF, LVL_IMPL, TRUE,
           "SYSERR: Error making backup news file (%s)", buf);
    return;
  }

  if (!(fl = fopen(buf, "r"))) {
    mudlog(BRF, LVL_IMPL, TRUE,
           "SYSERR: Error opening backup news file (%s)", buf);
    return;
  }

  if (!(new = fopen(NEWS_FILE, "w"))) {
    mudlog(BRF, LVL_IMPL, TRUE,
           "SYSERR: Error opening new news file (%s)", NEWS_FILE);
    return;
  }

  while (get_line(fl, line)) {
    if (*line != '[')
      fprintf(new, "%s\n", line);
    else {
      strcpy(last_buf, line);
      break;
    }
  }

  rawtime = time(0);
  strftime(tmstr, sizeof(tmstr), "%b %d %Y", localtime(&rawtime));

  sprintf(buf, "[%s] - %s", tmstr, GET_NAME(ch));

  fprintf(new, "%s\n", buf);
  fprintf(new, "%s\n", argument);

  if (strcmp(buf, last_buf))
    fprintf(new, "%s\n", line);

  while (get_line(fl, line))
    fprintf(new, "%s\n", line);

  fclose(fl);
  fclose(new);
  reboot_news();
}

2. Close act.wizard.c

3. open act.h and under do_zunlock add:
	
ACMD(do_patch)

4. close act.h and open interpreter.c

5. search pardon and under it add:

  { "patch"    , "patch"   , POS_DEAD    , do_patch    , LVL_IMPL, 0 },

6.  close interpreter.c and open db.c

7.  search reboot_wizlists and under it add:

void reboot_news(void)
{
        file_to_string_alloc(NEWS_FILE, &news);
}

8.  close db.c and open db.h

9.  search reboot_wizlists and under it add:

void reboot_news(void);

10.  close db.h and compile.  :)

I hope you like this.  I think it brings use to the news file.  :)

- Liko 4/25/2014

Rumble
The Builder Academy
tbamud.com 9091

Please Log in or Create an account to join the conversation.

More
3 years 10 months ago #5173 by dracmas
Replied by dracmas on topic Patch Command
Second github? It would keep everything neat and in one place as well as easy to resort when needed.

Please Log in or Create an account to join the conversation.

  • Liko
  • Liko's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
3 years 9 months ago #5213 by Liko
Replied by Liko on topic Patch Command

dracmas wrote: Second github? It would keep everything neat and in one place as well as easy to resort when needed.


Sorry, I have been gone. How is it working? I took the basic idea from the news/motd and todo. Do you like it? Anything else do you think could be done with it?

DragonBall: Tournament (1.2.0)
Owner/Developer
The following user(s) said Thank You: dracmas

Please Log in or Create an account to join the conversation.

More
3 years 9 months ago #5220 by dracmas
Replied by dracmas on topic Patch Command
It's worked like a charm. Don't see anything that needs changed. Only I changed the command name to newsupdate as I want it easily known what the command does. Great job. Which reminds me. Going to go back and give you credit in the help file for the command.

Please Log in or Create an account to join the conversation.

Time to create page: 1.764 seconds