How to Apply a Patch

= Applying Patches =

What is a patch?
A patch is no more than a plain text file which contains data about the differences between two versions of the same file or files on a line-by-line basis. If a line changes in a file it is compared to the corresponding line in the original version of the file, and the old line along with the newer version are stored in the patch file. The end result is a list of instructions for updating the code of the original file so that it matches the code in the version it is compared to.

If you can compile the server, then you can compile patchs to the server. You will need [wiki:Eclipse], a copy of the source code and the patch file(s).

Collecting the Files
Patchs come in basically 2 types.

.java files .txt or other files

Download the desired patch file(s) to an empty temporary folder. Extract the files if you need to. (zip, rar)

Preparation to the Compile
If there are no .java files, proceed to the next section.

If the patch contains any .java file, you will need to place them in the correct location in the source code directory tree of [wiki:Eclipse]. These need to be placed in the [wiki:Eclipse] "workspace" / L2_GameServer / java / net / sf / l2j /  where ever. The txt. or other files, leave in the temporary folder.

Compilation
To compile we need to work in the Navigator screen.

Right click on L2_Gameserver. Select Team. Select Apply Patch.

A window opens, at the bottom, in Select Patch, toggle file and click Browse. Find the .txt file(s) that you placed in the temporary folder.

Click Next.

If you have red ''' ! ''' you will need to make sure you are using the same version of the source code and find out from the forum if there are any problems with this patch.

If the patch was developed right and you have the correct version of source code, then all the check marks will be correct. Click Finish and then Compile as you would normally in the Ant menu.

How to edit by hand
This is how to do it by hand.

This is what part of a .txt patch file looks like. - means to remove the line + means to overwrite with this info

Here is part of the GMInventory by ootz0rz for an example:

Index: java/net/sf/l2j/gameserver/clientpackets/SendWareHouseWithDrawList.java

=
====================================================== --- java/net/sf/l2j/gameserver/clientpackets/SendWareHouseWithDrawList.java   (revision 353) +++ java/net/sf/l2j/gameserver/clientpackets/SendWareHouseWithDrawList.java   (working copy) @@ -99,7 +99,9 @@           }         } -        if (finalCount > PcInventory.MAX_ITEMS) +       // ootz0rz +       // allow GMs to have unlimited inventory +       if (finalCount > PcInventory.MAX_ITEMS && !activeChar.isGM) {            for (int i = 0; i < items.length; i++) {

Index: java/net/sf/l2j/gameserver/clientpackets/SendWareHouseWithDrawList.java

This is the file that needs to be changed.

revision 353)

This is the revision it was made for.

@@ -99,7 +99,9 @@             }          }

These are the lines above the edit.

-       if (finalCount > PcInventory.MAX_ITEMS)

This is a line to find and remove.

+       // ootz0rz +       // allow GMs to have unlimited inventory +       if (finalCount > PcInventory.MAX_ITEMS && !activeChar.isGM)

This is what gets written where you removed the above line.

To get an older copy of Revisions
In Navigator window, Right click L2_GameServer -> Team -> Switch -> Type in revision number

What Version am I using?
In Navigator window, Right click L2_GameServer > Properties >Subversion

How to update Revisions
In the Eclipse navigator window. Right click L2_GameServer > Team > Update Then compile when finished.