Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ ROM
➜ Running the server
➜ Scan code
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Lumpei
(6 posts) Bio
|
Date
| Wed 03 Mar 2004 11:29 PM (UTC) |
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 | Top |
|
Posted by
| Nick Gammon
Australia (23,057 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 04 Mar 2004 12:01 AM (UTC) 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 | 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.
9,396 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top