• 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!

Proof of concept of a new game engine

Mechanics
Basically we have to decompile Cipsoft’s leaked binary and implement all mechanics based on that. It’s actually not that hard, I played with it yesterday, first you need to decompile it to C pseudocode using IDA Pro with HexRays and then to make it readable you just have to convert some variables to proper structs and rename them. But it's for sure a lot of manual work.
IDA seems to have trouble recognizing variables names and sometimes messes up the order of arguments in pseudo C. I suggest using two or three different decompilers and compare the output to make a better sense out of it. But you'll often need to look into ASM anyway. Feel free to leave me a PM when you need an assistance, and good luck with your project.
 
@bpawel10 A great project, I keep my fingers crossed for it. If you need help with how certain mechanics work, you know where to find us. I would love to make a small contribution to the code, but I'm currently overloaded with work until 2177.
Good luck

imho decompiled cip engine is more readable and clean than tfs sources
 
Last edited:
IDA seems to have trouble recognizing variables names and sometimes messes up the order of arguments in pseudo C. I suggest using two or three different decompilers and compare the output to make a better sense out of it. But you'll often need to look into ASM anyway. Feel free to leave me a PM when you need an assistance, and good luck with your project.
Using multiple tools for the same job does not seem like a thing that we should do.
Going through 3 versions of pseudo-code just to end up reading assembly does not sound like the best idea.
Some of the IDA argument issues could be solved with plugins, and it feels better to dwell on the problem instead because other decompilers might have them too.
 
To do that in this engine, you have to know Rust very well, but you can implement everything by creating new systems. If you need to store a list of casts, you can create a new attribute inside a new system and add it to the game. If you need to store some additional cast data in player entity, you can create an attribute for that as well. If you need a new tcp listener for cast spectators, you can do it in system, inside a task. And then people can just copy paste these files, enable them in config and it'll work.
Kasteria/Tibijka/Eloth can keep cast system with 2500 online, because it's in best possible place to make it: C++. Taking care about every byte copied in RAM and how it caches in processor caches.
Other problem is that, making new cool features would be super easy.. if you don't care about 1997 tibia client and protocol. Protocol isn't really bad. It's designed for 1000+ online and low connection speed usage (server side), but not for new custom features.

There is always one simple graph:
1632503584289.png

Where is that engine? Aiming to make it easy to create pokemon ots, but not ready to handle 500+?
It's not bad plan. 90% of servers don't go over 200 online.
 
Using multiple tools for the same job does not seem like a thing that we should do.
Going through 3 versions of pseudo-code just to end up reading assembly does not sound like the best idea.
Some of the IDA argument issues could be solved with plugins, and it feels better to dwell on the problem instead because other decompilers might have them too.
@Kaspar why does admins let this user keep posting out of topic comments against a certain user? Whole posts were deleted yet he is again here posting non-sense content, this is disrespectful to the OP, everyone i know who have RE cipsoft binaries have went through the same.
@bpawel10: It's a very good idea to take RealOts as a model, it's thousands million better than TFS and any other server that is mentioned/advertised above this post.
 
because it's in best possible place to make it: C++
Where is that engine? Aiming to make it easy to create pokemon ots, but not ready to handle 500+?
Well, it looks like you don't know what Rust is, but I can explain it for you.

Rust is a systems programming language compiling to machine code, and it can be as fast as C++. It's famous for its memory safety feature, meaning you can't have things like use after free, double free, buffer overreads/overwrites, null pointers, data races etc., and your code is checked for all those issues at compile time, so there's no runtime overhead. It's not another high level language with garbage collector, it's a C++ successor.

Of course it doesn't mean people will now rewrite everything to Rust (but a lot of Rustaceans would probably want to), but new projects will for sure consider it. You can also find a lot of stories of big tech companies that benefited a lot from rewriting some key parts of their code. I'll just link one example of Discord, and notice that they did it back in 2019. There are even plans to allow writing Linux Kernel drivers in Rust (or maybe it's already allowed, I haven't checked it for a while). It's just a better C++, and not only because it's just as fast as C++ but much more safer at the same time, it's syntax and features are also much better because it just took the best parts of other languages. I can mention two really cool features that made many people love this language: enums that can store different data in each variant, and of course - no null!
 
if you don't care about 1997 tibia client and protocol. Protocol isn't really bad. It's designed for 1000+ online and low connection speed usage (server side), but not for new custom features.
Can you elaborate more about the protocol? So if we have the freedom to change it what we would change? My only idea was using protobuf.
Kasteria/Tibijka/Eloth can keep cast system with 2500 online, because it's in best possible place to make it: C++. Taking care about every byte copied in RAM and how it caches in processor caches.
In some places like getspectators its totally true, there some few key improvements there related to memory cache/access which improves performance a lot. About handling 2500 players, i think its depends. Botters and people in tranining monks do not costs much in terms of professing power. The real test comes with a world boss with 500+ players in the same screen fighting it. Also important to know TFS has many "random" lags which aren't noticed by us devs or players like old decay system, player saving/loading, some huge(and badly made) lua script that do too many things in one run. I remember you fixed the decay and player saving/loading.
Another important fact, not many systems are moved to lua yet.

There is always one simple graph:
View attachment 62310

Where is that engine? Aiming to make it easy to create pokemon ots, but not ready to handle 500+?
It's not bad plan. 90% of servers don't go over 200 online.
I totally agree with you. But then you can build this game server with a scripting language(which will beat rust/c++ in productivity) since performance(and handling a lot of players) is not an issue.
I believe there is a misconception in your graph btw, current RL Tibia requires a lot of custom scripts. Old school Tibia is a piece of cake compared to current Tibia.
Post automatically merged:

@Kaspar why does admins let this user keep posting out of topic comments against a certain user? Whole posts were deleted yet he is again here posting non-sense content, this is disrespectful to the OP, everyone i know who have RE cipsoft binaries have went through the same.
@bpawel10: It's a very good idea to take RealOts as a model, it's thousands million better than TFS and any other server that is mentioned/advertised above this post.
I'm very curious to know which is "realots" model and why its millions better than TFS. Its important to start a engine project knowing such details and all the community can benefits from this discussion.
 
Last edited:
Can you elaborate more about the protocol? So if we have the freedom to change it what we would change? My only idea was using protobuf.

In some places like getspectators its totally true, there some few key improvements there related to memory cache/access which improves performance a lot. About handling 2500 players, i think its depends. Botters and people in tranining monks do not costs much in terms of professing power. The real test comes with a world boss with 500+ players in the same screen fighting it. Also important to know TFS has many "random" lags which aren't noticed by us devs or players like old decay system, player saving/loading, some huge(and badly made) lua script that do too many things in one run. I remember you fixed the decay and player saving/loading.
Another important fact, not many systems are moved to lua yet.


I totally agree with you. But then you can build this game server with a scripting language(which will beat rust/c++ in productivity) since performance(and handling a lot of players) is not an issue.
I believe there is a misconception in your graph btw, current RL Tibia requires a lot of custom scripts. Old school Tibia is a piece of cake compared to current Tibia.
Post automatically merged:


I'm very curious to know which is "realots" model and why its millions better than TFS. Its important to start a engine project knowing such details and all the community can benefits from this discussion.
It's million times better than TFS because it works flawlessly, anyone who have played in the cipsoft engine can notice it. CIP compiled their server in debugging mode, so you have a lot of info available for you to dump from the tarball, even though IDA and Ghidra do most of the work for you, you will find the problems explained in some posts above.

The code itself is way more readable and clean than any public distro you will find around, TFS included.
The memory management is way better.
Same as Nostalrius distro, we already have the files for npcs, items, monsters, actions, etc 100% correct in there, no need to lose time re-writting them, and you can use the same interface for anything you want.
A lot of basic features missing in TFS are already there, like monster virtual inventory, monsters skill gaining feature, monster AI, etc.
I know of someone who fused moveuse.dat into his custom map editor and created Move/Use rules directly from an user interface, without writing it by hand.

So you can start it from TFS where ppl is waiting for a year to get a simple icon for it instead of have the basic features exposed above implemented, or you can feed yourself from the cipsoft binaries where most of it is implemented and working just fine. I guess the OP already realized it and that's why he want to get the mechanics from the real thing.
 
Last edited:
It's million times better than TFS because it works flawlessly, anyone who have played in the cipsoft engine can notice it. CIP compiled their server in debugging mode, so you have a lot of info available for you to dump from the tarball, even though IDA and Ghidra do most of the work for you, you will find the problems explained in some posts above.

The code itself is way more readable and clean than any public distro you will find around, TFS included.
The memory management is way better.
Same as Nostalrius distro, we already have the files for npcs, items, monsters, actions, etc 100% correct in there, no need to lose time re-writting them, and you can use the same interface for anything you want.
A lot of basic features missing in TFS are already there, like monster virtual inventory, monsters skill gaining feature, monster AI, etc.
I know of someone who fused moveuse.dat into his custom map editor and created Move/Use rules directly from an user interface, without writing it by hand.

So you can start it from TFS where ppl is waiting for a year to get a simple icon for it instead of have the basic features exposed above implemented, or you can feed yourself from the cipsoft binaries where most of it is implemented and working just fine. I guess the OP already realized it and that's why he want to get the mechanics from the real thing.
Cipengine is more consistent, it has a game loop but its a 20 fps/hertz engine, which means a 50 ms beat which sucks. TFS/opentibia always been praised for being more smooth/realtime than cipengine. Also RL Tibia has software lag which make the ping higher.
Cipengine has way more rpg features.
Code more readable? not sure. But its more simple and smaller because the scope of the game is so small.
"The memory management is way better." no clue about that.
"A lot of basic features missing in TFS are already there, like monster virtual inventory, monsters skill gaining feature, monster AI, etc." they invested more in rpg features.
Their domain specific language used for the scripting of the game is very simple and the concept of condition -> action very similar to how age of empires 2 a.i worked is very nice. But its so limited that it sucks for anything that wants to leave the domain of the simple game they had in 2005 so its useful to re-utilize their content but it sucks for customization and more complex stuff. Look at annihilator lever implementation, its unsafe and huge.
 
Cipengine is more consistent, it has a game loop but its a 20 fps/hertz engine, which means a 50 ms beat which sucks. TFS/opentibia always been praised for being more smooth/realtime than cipengine. Also RL Tibia has software lag which make the ping higher.
Cipengine has way more rpg features.
Code more readable? not sure. But its more simple and smaller because the scope of the game is so small.
The first is configurable and perfectly enough. The latter (said "lag") comes from Nagle's algorithm, which isn't a software issue but tcp implementation and it's a matter of adjusting (network bandwidth used to be a bigger concern back then). In tfs and otc nagle is disabled by default and you can disable it in tibia client and server too by setting a flag on socket.
The cip server source was definitely way more readable, in some parts even the decompiled code is, which speaks for itself. As you said, it's simple, small and consistest, shows more of academic approach, while tfs is unnecessairly overbuilt and goes spaghetti, which is also reflected in resources usage on runtime.
Tfs might be "praised for smooth/realtime" but is it actually that smooth? Unlikely. E.g. it lags terribly when managing big stocks of items, especially when the action involves database, and tfs does rely alot on database (say saving / loading player's depot). It doesn't support multi-threading and inserts huge queries in the main thread. It exceeds to a point in which player can basicaly blow the server up with a stock that cip server could eat like a piece of cake.

"A lot of basic features missing in TFS are already there, like monster virtual inventory, monsters skill gaining feature, monster AI, etc." they invested more in rpg features.
Their domain specific language used for the scripting of the game is very simple and the concept of condition -> action very similar to how age of empires 2 a.i worked is very nice. But its so limited that it sucks for anything that wants to leave the domain of the simple game they had in 2005 so its useful to re-utilize their content but it sucks for customization and more complex stuff. Look at annihilator lever implementation, its unsafe and huge.
To be fair, missing features shouldn't be a point here as it's tfs trying to mimic real tibia, not the way around. Though it's true that it's still very far from the real thing.
But neither should be the limit of cip scripting, since it was limited to what they actually needed. It wasn't indended for anyone to customize what they like. Annihilator script unsafe? It's actually hard to break anything even with a faulty script, server checks the correctness of everything on start, while in tfs one defective lua script can result in unexpected crashes and you may have a hard time trying to determine the cause.
Should you have the sources, it would be easy to add new functions to cip syntax. Which is the crucial advantage tfs has, that you have full access to its sources. Unlike in cip engine which is also the reason I wouldn't recommend using it as an ot (unless you really know what you're doing). In other case this discusion would be pointless, cause cip server even being a relic still outmatches modern ots in general performance and reliability.
 
Last edited:
As a non tech savvy person from what i've seen so far in this thread it seems like Cipsoft is professional and ots creators are amateur. So that 2005 tibia "cip server even being a relic still outmatches modern ots in general performance and reliability"
 
As a non tech savvy person from what i've seen so far in this thread it seems like Cipsoft is professional and ots creators are amateur. So that 2005 tibia "cip server even being a relic still outmatches modern ots in general performance and reliability"
" Cipsoft is professional and ots creators are amateur." no shit. TFS is 16~ years old attempt to reproduce Tibia. The code is somehow modern C++ but the design choices aren't.
I think kay idealizes the cipengine since its the original deal and its somehow different from TFS, which makes it unique compared with the rest even if its not better.
The first is configurable and perfectly enough. The latter (said "lag") is caused by Nagle's algorithm, which in tfs and otc is already disabled by default. It's not a software issue but a matter of adjusting (network bandwidth used to be a bigger concern back then). You can disable Nagle in both tibia client and server by setting a flag on socket.
Nothing about nangle issue in the 7.7 cipengine, i said the current Tibia has software lags. Ping increases with more players, some events and wars lags the game server.

The cip server source was definitely way more readable, in some parts even the decompiled code is, which speaks for itself. As you said, it's simple, small and consistest, shows more of academic approach, while tfs is unnecessairly overbuilt and goes spaghetti, which is also reflected in resources usage on runtime.
It evolved from C code. A lot of code is inside the creature class instead of player. There is text messages and other things in the main game loop, i don't see it as a good code. Its simplier, but not better either.
"while tfs is unnecessairly overbuilt and goes spaghetti, which is also reflected in resources usage on runtime." I agree, anything that TFS has is overbuild for a 7.7 game.
Tfs might be "praised for smooth/realtime" but is it actually that smooth? Unlikely.
In general, it is. Players can't perceive the random lags and they rarely happen.
it lags terribly when managing big stocks of items, especially when the action involves database, and tfs does rely alot on database (say saving / loading player's depot). It doesn't support multi-threading and inserts huge queries in the main thread. It exceeds to a point in which player can basicaly blow the server up with a stock that cip server could eat like a piece of cake.
Its true but that did not prevent me from having 1800 players online without lags. TFS approach to database is a very bad one, since its so easy to save/serialize stuff to the dabase when you need in a sync fashion.
Multi threading in TFS is a joke, everything is done by dispatcher(world simulation) and asio thread. Cipengine uses raw files for character(bad choice) but at least they cache the players so loading them is not that expensive. TFS could be greatly improved if there was something like a query manager that just answered TFS with the data it need in async fashion.
The fact that Cipengine invested way more engineering into this because they were a professional company with many players online in a single monolithic server + shit hardware(way worst than we have today) so they had to make it work performance wise.
Though it's true that it's still very far from the real thing.
Not really. Its just no one invested in having a consistent action system for creatures(specially player actions) and rpg features.
Its just a ugly mimic of Tibia without the care of being an actual game, which OT players almost never bother to pay attention to the flaws.
But neither should be the limit of cip scripting, since it was limited to what they actually needed. It wasn't indended for anyone to customize what they like. Annihilator script unsafe? It's actually hard to break anything even with a faulty script, server checks the correctness of everything on start, while one defective lua script can cause unexpected crashes and you may have a hard time trying to determine the cause.
Should you have the sources, it would be easy to add new functions to cip syntax. Which is the crucial advantage tfs has, that you have full access to its sources. Unlike in cip engine which is also the reason I wouldn't recommend using it as an ot (unless you really know what you're doing). In other case this discusion would be pointless, cause cip server even being a relic still outmatches modern ots in general performance and reliability.
Try to imagine implementing current RL Tibia with such scripting.
Like i said, as a domain specific language made for the condition -> action design, its simple and elegant. Try to make anything more complex than that and it will be ugly.
In order to be more productive, a full-fledged scripting system with a language like Lua where you can develop new systems/features is better and game changing. This is where the cipengine really sucks, customization.

The good things i think are worth to learn from cipsoft engine are:
Game loop which simplies a lot of things and add consistence to the world/game simulation
Rpg features(player actions, A.I, monsters gaining skills, monsters being in defense mode while walking, saving the map in the server save, etc)
Database Manager(async layer with the database for the game server, no sql)
simple condition -> action design
Item id instead of server id(fuck items.otb)
disguise items
npc dialogs system(condition -> action design)
randomization in few places which add to the idea of throwing dices while playing
more logging of player actions?

There is more, but i don't remember at the momment.
 
Last edited:
Nothing about nangle issue in the 7.7 cipengine, i said the current Tibia has software lags. Ping increases with more players, some events and wars lags the game server.
I thought we were speaking about the stolen engine. Current Tibia is irrelevant, because we have zero insight to its back-end. Neither you or I may have any clue where those supposed lags are caused at, let alone judge it's software lag, so there's nothing to discuss.

I think kay idealizes the cipengine since its the original deal and its somehow different from TFS, which makes it unique compared with the rest even if its not better.
Nothing is idealized. Nowhere I said cip engine was an engineering marvel, I'm talking about its performance and reliabilty in relation to tfs. So yes, it is better in that regard, which you've just confirmed yourself.
In the same time it's worse for customization purposes, true, even apart from the fact you have no sources, customization wasn't their goal. Cip server and tfs had different targets. Tfs aims to be ran by other people, who often don't even know how to compile it, so it attempts to put the whole game into configurable and compatible scripts (unsuccesfully), which cip did not.
If you compare them in terms of traits that were their common goals, cip is better (performance, reliablity, readable code). But as I said I wouldn't recommend running it as an ot, unless you're sure what you're doing, because you may struggle with the simplest customization.

A lot of code is inside the creature class instead of player.
Player is a creature, just as a monster and NPC, so of course the common code will be in the base class. What is that you say should be put in player instead?

In general, it is. Players can't perceive the random lags and they rarely happen.
"In general" anything can be, cause this claim lacks a point of reference. Sure it can be played with no lags (atleast until someone decides to pack 100k items to his depot 😆), but so can be the cip engine. You've mixed two perspectives, engineering for cip server ("it sucks cause of 50 ms beat") vs player's general feel for tfs ("generally smooth").

Reading the rest of your post I guess we can agree anyway. Cip engine is of an old standard, but made a good use of it, while tfs uses higher level stuff, but de facto only pretends or aspire to be modern.
I don't have a knowledge to tell whether the OP's choices are best, but I like the approach. It shows more care than tfs which mostly chooses to be - as you called it - an ugly mimic. Would gladly help regarding reverse engineering the real mechanics when it comes to that.

with 2500 online, because it's in best possible place to make it
It's not a measure when 2000 of them are x-logged on trainers, take into account the actual players.
 
Last edited:
I thought we were speaking about the stolen engine. Current Tibia is irrelevant, because we have zero insight to its back-end. Neither you or I may have any clue where those supposed lags are caused at, let alone judge it's software lag, so there's nothing to discuss.


Nothing is idealized. Nowhere I said cip engine was an engineering marvel, I'm talking about its performance and reliabilty in relation to tfs. So yes, it is better in that regard, which you've just confirmed yourself.
In the same time it's worse for customization purposes, true, even apart from the fact you have no sources, customization wasn't their goal. Cip server and tfs had different targets. Tfs aims to be ran by other people, who often don't even know how to compile it, so it attempts to put the whole game into configurable and compatible scripts (unsuccesfully), which cip did not.
If you compare them in terms of traits that were their common goals, cip is better (performance, reliablity, readable code).

I played pretty much all meaningful ots servers past 10-12 years and yes original cipsoft client and server seems to perform head and shoulders above any amateur project (ots) when it comes to performance ( cipsoft one is rock solid and very stable ) and reliability ( i did not encounter any bugs in cipsoft client and servers whereas on ots i always found something wrong). I can't speak for others but from my point of view the "smooth" feeling on most ots is fake because it's usually caused by some movement optimizations rather than server working well and on rl tibia that's not the case because there everything worked as expected and this fake feeling of smoothnes is not needed when everything just works. Let me remind you last time those are my observations based on 11 years of experience in playing on ots and not knowledge based on analyzing under the hood code.
 
is there a discord server (or could you make one) for this? could be nice to have more in-depth discussions and watch the development process
looks interesting and promising imo either way, keep it up 👍
 
Pardon my pragmatism, but all you have to do is launch two clients (optimized otc on accordingly prepared tfs vs Cip's stack) along and see for yourself and it will be visible on anything 30hz+, not to mention 120Hz+ screens.

With all due respect to the work some of you guys put into parsing cams and making sure that everything is as "7.4" as it can get, I also tried with your modified cip's stack (that's what you are guys using, right? @kay ) there is not much improvement over OG cip's stack from a user perspective.

Tibia is a "returning player" game, and these hardly remember how laggy it was and won't find any nostalgia in desync.
RE everything to get to know how it originally was, but don't get too attached to being 1:1 with client choppiness, because that's not what players usually want.

If you will still disagree with me ill try to scrap out some footage to make the cip stack issues more visible, but please remember not to take it too personally.
I'm addressing them in hope that someday you will be able to fix the them aswell

It's not a measure when 2000 of them are x-logged on trainers, take into account the actual players.
500 players would be still more than you were able to benchmark yourself, so it would be wise to not discredit Gesior's words.
As far as I recall the heaviest load on your launch caused some issues.

while tfs uses higher level stuff, but de facto only pretends or aspire to be modern.
Do you have anything to back it up?
I'm not claiming that it's perfect, but some of the contributions are very high quality and your words might be insulting/discouraging to some people.
You can be there to point out the issues with the contributions, even without suggesting any solutions - but I never saw it happen, did it?

why does admins let this user keep posting out of topic comments against a certain user? Whole posts were deleted yet he is again here posting non-sense content, this is disrespectful to the OP, everyone i know who have RE cipsoft binaries have went through the same.
I'm writing my post because I have a different perception that I'd like to share.
You said that people do it the easy way, so you prove yourself it's valuable.
If that's over your point of understanding - I'm sorry, but I still doubt that's a reason to tag anyone nor delete my posts
 
Last edited:
Back
Top