[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  ROM
. -> [Folder]  Running the server
. . -> [Subject]  Scan code

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Scan code

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Lumpei   (6 posts)  [Biography] bio
Date Wed 03 Mar 2004 11:29 PM (UTC)  quote  ]
Message
Greetings, All!

First of all, I am a complete neophyte to all this but very excited about hosting my own mud.

I am running the w32 version of Rom 2.4 on XP, and i am interested in learning how to add code now. i just downloaded Erwin Andreasen's code for 'scan' and, well, i haven't the faintest idea of how to implement it. The hypercube faq mentions running a patch command, to which i reply, 'huh?'

Oh, i also compiled this and am running it on cygwin.

So, please pardon how green I am and if anyone has info to help me, that would be great! I am not interested in writing my own code (yet), just learning how to patch it.

Peace, y'all!

Lumpei
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 04 Mar 2004 12:01 AM (UTC)  quote  ]

Amended on Thu 04 Mar 2004 12:02 AM (UTC) by Nick Gammon

Message
Minor changes to code are often distributed as "diff" files, which are made by comparing a piece of code before a change to one afterwards.

For example, if I add a line to a file, delete one, and change one, and then do this:

diff fight.c.orig fight.c

I get something like this:


182d181
<     ch->fearing->who  = victim;
228a228
> // added a comment here
264c264
<       do_shout( ch, "Thoric says, 'Prepare for the worst!'" );
---
>       do_shout( ch, "Nick says, 'Prepare for the worst!'" );



This is showing that:


  • I deleted line 182
  • I added something at line 228
  • I changed something on line 264


It is a bit easier to see if you do a "context diff" which shows the context of the change:

diff -c fight.c.orig fight.c


*** fight.c.orig        2004-03-04 10:55:00.000000000 +1100
--- fight.c   2004-03-04 10:55:27.000000000 +1100
***************
*** 179,185 ****

      CREATE( ch->fearing, HHF_DATA, 1 );
      ch->fearing->name = QUICKLINK( victim->name );
-     ch->fearing->who  = victim;
      return;
  }

--- 179,184 ----
***************
*** 226,231 ****
--- 225,231 ----
   */
  void violence_update( void )
  {
+ // added a comment here
      char buf[MAX_STRING_LENGTH];
      CHAR_DATA *ch;
      CHAR_DATA *lst_ch;
***************
*** 261,267 ****
        bug( "Short-cutting here", 0 );
        ch->prev = NULL;
        gch_prev = NULL;
!       do_shout( ch, "Thoric says, 'Prepare for the worst!'" );
    }

    /*
--- 261,267 ----
        bug( "Short-cutting here", 0 );
        ch->prev = NULL;
        gch_prev = NULL;
!       do_shout( ch, "Nick says, 'Prepare for the worst!'" );
    }

    /*



Now you can see the "before" and "after" (in bold). The "+" means "add a line", the "-" means "subtract a line", and the "!" means "change this line".

To use a patch file (diff file) you simply navigate to the directory where your file is (or maybe the parent directory, read the instructions if any), and then type:

patch < diff-file

This runs the patch program, feeding the diffs to it, which it then incorporates into your source.

The nice thing about context diffs is that even if you have added code of your own, it uses the context to try to find the right spot, even if the right spot is now 20 lines further on, or further back.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


1,556 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]