• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Keep files up to date

ianelli

Ramza
Joined
Mar 18, 2010
Messages
125
Reaction score
47
Location
Brazil
Hi, i wanted to know if somebody could help me with one question.
Let's say i get a version of the source code TODAY, and use that to create a project that is somehow different from the otclient 'type', so, i cannot commit it.
BUT, i want to keep it updates with the changes that happens, but without having to re-download it everytime..
I think git do that part, but can somebody tell me how?
 
My recommendation is that you do not change any C++ code in the sources and avoid changing core modules (like corelib, gamelib and game_interface). If you need any change then use new modules to add new functionality or overwrite the current modules. There is a system for overwriting modules, scripts and images using the "mods" directory, I will try to explain how to do this the correct way here.

Let me explain how the mods directory works, first run this command in otclient's terminal, you should get an output similar to mine:
> table.dump(g_resources.getSearchPaths())
1: /home/bart/coding/otclient/mods
2: /home/bart/coding/otclient/modules
3: /home/bart/coding/otclient/data
4: /home/bart/.otclient

Otclient search for any file in these paths, in order, first it tries to search in the first path, then the second and so on. For example, if I'm trying to load "/images/clienticon.png
it will look first in "/home/bart/coding/otclient/mods/images/clienticon.png", if the image is not found there, then in "/home/bart/coding/otclient/modules/images/clienticon.png", if the image is not found there neither, finally it will look in "/home/bart/coding/otclient/data/images/clienticon.png". What does this mean? That you can still change clienticon.png without touching the otclient's data or modules directory, and this also works for scripts, otuis or any file.

Knowing that, I will show four specific cases for customizing the client with examples.

First case, change a game module:
Let suppose that you want to change the inventory layout, because you do not need the standard tibia layout. To do that you would need to change "modules/game_inventory/inventory.otui", however you do not want to change that file directly, because you still need compatibility with latest otclient sources. So to do that corretly, you copy the file to "mods/game_inventory/inventory.otui", and then make your changes there. Because g_resources will look for "mods/game_inventory/inventory.otui" first, the standard otclient's file in "modules/game_inventory/inventory.otui" will be ignored. You can use the same ideia to change, battle, viplist, images, styles, etc.

Second case, add a new module:
Lets suppose that you want to create a new module for a new cool interface that interacts with your game. First you create the module inside mods directory, then configure autoloading in the module, to make it always load. If your need any protocol change you can use the extended opcode, there is patch for tfs sources inside tools directory to enable extended opcode in your server, alternatively you could use tfs trunk, because it is already patched.

Third case, change core functionality:
Changing core functionality would need to change the C++ source codes or lua modules that is dependency for many other modules that are used everywhere, you should avoid that because the otclient devs is frequently updating these codes and maintaining your own difference while keeping up to date would make your life much harder. In this case, first see if the scenario can fit the official otclient sources, if so try to contribute to our repository, then your changes will be inside otclient sources, making your life easier and would also help to make otclient more flexible. There are many codes already inside otclient that work this way, the g_game.enableFeature() is an example, where you can disable/enable features depending in the protocol, and there even extra features not used by tibia there, like changing the effects from U8 to U16.

Fourth case, change core functionality for experienced users who knows git:
So you need to change core functionality, but it doesn't fit otclient official sources. What you want to do is known as fork for git users, you will need to create a fork of the project as a git branch in your local git repository. I'm not going in many details but what you have to do is to clone the otclient sources, then create a branch for your project, commit your own changes in there, then whenever otclient is updated, you first use "git fetch" to download latest otclient source, then "git rebase" to rebase your changes in the latest otclient sources, this will reapply everything that you changed over the latest otclient code, alternatively you can use "git merge" if really changed a lot of codes. However I do not recommend this for anyone, unless you really know what you are doing, and you already master git.

In summary, try to keep all the changes inside "mods" directory, whenever you cannot maintain the changes there, contribute to the otclient project to improve its flexibility. A good project made with otclient would always work with the latest official otclient core modules and binary release, even if you do not compiled yourself. You should use just the lua API to make your whole client project.
 
Last edited:
There are some things that are hardcoded and I'd like to edit them. For example the healthbars on game map iirc. And I have no idea how to draw anything new there using scripts. Any suggestions?
 
If you're doing something great with otclient sooner or later you'll need to use bart's 'Third case'.

So, starting from now:
DO NOT USE OTCLIENT WITHOUT GIT!

Otclient is not complete, so eventually you'll need to create an Event, or bind a Lua function, etc.
When you make so, do a pull request and we'll read it.
If you've done it right, we'll put your commit inside official repository.
Otherwise, we'll tell what's wrong and how to fix it.
 
Well, I'll try doing few things. I wanted to do something between fc hud and icehud for wow. Displaying health and mana together, targets health, status icons. But all that will be easy after moving drawing names and healthbars to modules. I hope that I'll be able to do it in acceptable way

Ok, I know what I need. Ability to draw where I want and some drawPrimitive with hardcoded options and it will work pretty well. Drawing it by pixel would kill any machine probably.

There are also other changes, much more 'core' I'd like to add. Optional support for signed int floors for example. Increasing size of game window would be good also. I'm pretty sure that ambitious people here would love to see things like this. And proper fixes for server side. But there are huge changes that most of 'hosters' won't care about
 
Last edited:
Code:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)

This function content should be moved to lua.
Maybe you can add Widgets to creatures and they are rendered in this function.
Don't know for sure what is the best way to do this.

However it's not a priority, so main devs wont make this.
If you want to contribuite, make a pull request and for sure we'll implement it.
 
Now I'm working on core features of server, this is less important for me too :D
But some day I'll get to this and maybe even achieve something
 
Back
Top