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

help to understand how ots really work.

serigo

New Member
Joined
Jul 20, 2016
Messages
3
Reaction score
0
Hi i need help to understand how otserv really work.

I just downloaded this server TheForgottenServerV8.2 and there are many things that i dont understand for example i was looking into the folders and on data/xml there is a file called Groups.xml which is the file responsible for telling if someone is a player or a CM or a GOD here is a part of the code:

<group id="6" name="God" flags="3845069447162" customFlags="2097151" access="5" violationReasons="23" nameViolationFlags="426" statementViolationFlags="469" depotLimit="5000" maxVips="500" outfit="302"/>

what i wish to understand is from where all those elements like id , flags ,customFlags, access, come and from where all those numbers that they have are coming because i dont understand how the server knows what.
access = "5" means.

Is there a place where i can acess the source code of it all? is the answer for my question above on those .dll files? how do i access them?

i have been searching on the internet for all those answers but i havent found anything useful :( can anyone help me understand those things?haha

Thank you very much
 
Everything your wanting to know comes from the source code.
Unfortunately if the source code was not distributed with your version, you won't have the source code.
The .dll files are not the source code. Source code is all in c or c+/++. Usually ending in .cpp and another 2-4 extensions, which all work together.

The flag values can be found in "const.h".
They work by using none repeating numbers, that can't equal another value by adding them in different ways.
I believe it's an ever expanding number to the power of 2.
So to create the flag value you simply add each one together, so the value you want the players to have.
1 + 2 + 4 + 8 + 16 + 32 - et cetera.

Access is simply the elevation of the account in the database.
You can do it for an entire account, or on a character by character basis.

Been sitting idle here for 3 hours. Too busy at work to continue writing.
 
I believe it's an ever expanding number to the power of 2.
So to create the flag value you simply add each one together, so the value you want the players to have.
1 + 2 + 4 + 8 + 16 + 32 - et cetera.
How inconviniet it is, what a bad programming. Ticket maybe?
 
How inconviniet it is, what a bad programming. Ticket maybe?
How is it inconvenient?
At most you have to add up the numbers once or twice.
If your satisfied the way the values are set-up to begin with, then you never even have to touch them.
If you look in the source the values for each flag are already green-texted, you just have to copy the number -> paste into calculator -> press the addition button, repeat for every special flag you want.
There's also flag calculator's floating around the forum if your too lazy to add up the numbers yourself.
 
Good programer is lazy one bacause he develops solution not requiring extra work like opwning a calc to know variable meaning/value
 
Last edited:
How is it inconvenient?
At most you have to add up the numbers once or twice.
If your satisfied the way the values are set-up to begin with, then you never even have to touch them.
If you look in the source the values for each flag are already green-texted, you just have to copy the number -> paste into calculator -> press the addition button, repeat for every special flag you want.
There's also flag calculator's floating around the forum if your too lazy to add up the numbers yourself.
Thank you very much for explaining it to me :)) i got the source code now and i will try to make my own things, i have only one more question that is.. for what is flag for? i didnt understand it for example in the code is written this:
enum PlayerFlags : uint64_t {
PlayerFlag_CannotUseCombat = 1 << 0,
PlayerFlag_CannotAttackPlayer = 1 << 1,
PlayerFlag_CannotAttackMonster = 1 << 2,
PlayerFlag_CannotBeAttacked = 1 << 3,
.....
}

flags="3845069447162" customFlags="2097151" what that above has to do with this? or is not related at all?
 
Thank you very much for explaining it to me :)) i got the source code now and i will try to make my own things, i have only one more question that is.. for what is flag for? i didnt understand it for example in the code is written this:
enum PlayerFlags : uint64_t {
PlayerFlag_CannotUseCombat = 1 << 0,
PlayerFlag_CannotAttackPlayer = 1 << 1,
PlayerFlag_CannotAttackMonster = 1 << 2,
PlayerFlag_CannotBeAttacked = 1 << 3,
.....
}

flags="3845069447162" customFlags="2097151" what that above has to do with this? or is not related at all?
X << N
This "<<" is a left shift bitwise operation. It will shift all bits (binary) in X number, N times to the left.
So doing this with the number 1 will result in powers of 2 because you will get:

1 << 0 = B1 = 2^0 = 1
1 << 1 = B10 = 2^1 = 2
1 << 2 = B100 = 2^2 = 4
etc...

So when you want to mix different flags you just sum them.

In this case the flags value is 3845069447162 that gives:
Code:
0000000000000000000000110111111100111111111111111001111111111010
In uint64 (unsigned 64 bits)

So in this case you can see which flags are active by using the bitwise and (&)

It works like this:
You have numbers in binary:
x = 1100(12) and y = 1000(8)

x & y is going to return 1000 (8) so you can use this to check if some bit is on or off.

You can learn more searching about Bitwise in Google there are plenty of good tutorials about it.

This one is pretty good: http://code.tutsplus.com/articles/understanding-bitwise-operators--active-11301
 
Last edited:
X << N
This "<<" is a left shift bitwise operation. It will shift all bits (binary) in X number, N times to the left.
So doing this with the number 1 will result in powers of 2 because you will get:

1 << 0 = B1 = 2^0 = 1
1 << 1 = B10 = 2^1 = 2
1 << 2 = B100 = 2^2 = 4
etc...

So when you want to mix different flags you just sum them.

In this case the flags value is 3845069447162 that gives:
Code:
0000000000000000000000110111111100111111111111111001111111111010
In uint64 (unsigned 64 bits)

So in this case you can see which flags are active by using the bitwise and (&)

It works like this:
You have numbers in binary:
x = 1100(12) and y = 1000(8)

x & y is going to return 1000 (8) so you can use this to check if some bit is on or off.

You can learn more searching about Bitwise in Google there are plenty of good tutorials about it.

This one is pretty good: http://code.tutsplus.com/articles/understanding-bitwise-operators--active-11301
thank you very much for the explanation :)

dude /\ this is awesome thank you for sharing
 
Last edited by a moderator:
Back
Top