Jump to content
  • 0

frozen isInsideZone()


Question

Posted

It's not seem little nonsense on frozen this functions?

public static final int ZONE_PVP = 1;
	
	/** The Constant ZONE_PEACE. */
	public static final int ZONE_PEACE = 2;
	
	/** The Constant ZONE_SIEGE. */
	public static final int ZONE_SIEGE = 4;
	
	/** The Constant ZONE_MOTHERTREE. */
	public static final int ZONE_MOTHERTREE = 8;
	
	/** The Constant ZONE_CLANHALL. */
	public static final int ZONE_CLANHALL = 16;
	
	/** The Constant ZONE_UNUSED. */
	public static final int ZONE_UNUSED = 32;
	
	/** The Constant ZONE_NOLANDING. */
	public static final int ZONE_NOLANDING = 64;
	
	/** The Constant ZONE_WATER. */
	public static final int ZONE_WATER = 128;
	
	/** The Constant ZONE_JAIL. */
	public static final int ZONE_JAIL = 256;
	public static final int ZONE_EVENT = 257;
	/** The Constant ZONE_MONSTERTRACK. */
	public static final int ZONE_MONSTERTRACK = 512;
	
	/** The Constant ZONE_SWAMP. */
	public static final int ZONE_SWAMP = 1024;
	
	/** The Constant ZONE_NOSUMMONFRIEND. */
	public static final int ZONE_NOSUMMONFRIEND = 2048;
	
	/** The Constant ZONE_OLY. */
	public static final int ZONE_OLY = 4096;
	
	/** The Constant ZONE_NOHQ. */
	public static final int ZONE_NOHQ = 8192;
	
	/** The Constant ZONE_DANGERAREA. */
	public static final int ZONE_DANGERAREA = 16384;
	
	/** The Constant ZONE_NOSTORE. */
	public static final int ZONE_NOSTORE = 32768;
	
	/** The Constant ZONE_MULTIFUNCTION. */
	public static final int ZONE_MULTIFUNCTION = 67229;
	public static final int ZONE_GRAND = 134458;

	/** The _current zones. */
	private int _currentZones = 0;

	/**
	 * Checks if is inside zone.
	 * @param zone the zone
	 * @return true, if is inside zone
	 */
	public boolean isInsideZone(final int zone)
	{
		return (_currentZones & zone) != 0;
	}
	/**
	 * Sets the inside zone.
	 * @param zone the zone
	 * @param state the state
	 */
	public void setInsideZone(final int zone, final boolean state)
	{
		if (state)
		{
			_currentZones |= zone;
		}
		else if (isInsideZone(zone))
		{
			_currentZones ^= zone;
		}
	}
	

 

10 answers to this question

Recommended Posts

  • 1
Posted (edited)

it is 'hardcoded'. for better performance change it by urself.

 

8 |= 2 is like 8 = 8 | 2 .  = 10 (see that like 8+= 2)

 

it means

   1000 (binary)

|  0010 (binary)

  ----------

   1010 (binary)= 10 (decimal)

 

| is bitwise OR

 

possible results: 0,1 . return 1 as result if either of its inputs are 1 and will produce a 0 output if both of its inputs are 0.

 

see this

 

0     0     =     0

0     1     =     1

1     0     =     1

1     1     =     1

 

 

 

8 & 2 = 0 .

it means

    1000 (binary)

&  0010 (binary)

    ---------

    0000 (binary)= 0 (decimal)

 

& is bitwise AND.

 

possible results : 0,1. to get 1 as result both of the bits must be 1. otherwise the result will be 0.

 

see this:

 

0     0     =     0

0     1     =     0

1     0     =     0

1     1     =     1

 

 

 

 

8 ^= 2  is like 8 = 8 ^ 2 . = 10

it means

   1000 (binary)

^  0010 (binary)

   ---------

    1010 (binary) = 10 (decimal)

 

^ is a bitwise XOR

 

results 0,1. to get 1 as result must have only 1 of the bits the value 1.

 

see this:

 

 

0     0     =     0

0     1     =     1

1     0     =     1

1     1     =     0

 

One live example:

 

you are entering in oly zone.

 

setIsInsideZone(ZONE_OLY);

_currentZones from 0 will be 1000000000000

 

isInsideZone(ZONE_MOTHERTREE) 

ZONE_MOTHERTREE = 0000000001000

 

so... to get the result 1 of every pair , must both bits have value 1...  the result :

 

     4096

 &         8

---------------

0

 

 

     1000000000000 (binary) = 4096 (dec)

&   0000000001000 (binary) = 8 (dec)

------------------------------------

      0000000000000 (binary) = 0 (dec) 

 

isInsideZone:

return (_currentZones & zone) != 0;

 

Edited by melron
  • Thanks 1
  • 0
Posted
58 minutes ago, tazerman2 said:

in acis is isInsideZone(ZoneId.ZONE_MULTIFUNCTION)

in frozen is .isInsideZone(L2Character.ZONE_MULTIFUNCTION)

i not understand how it can work with frozen code?

  • 0
Posted (edited)

The addition or substraction of one of those zones never melt with another zone id (ex = the 3 first zones added don't reach 32, which is the next zone), therefore you can add/substract as much as you want. It is commonly used for zones ids, inventory slots, clan priviledges, etc.

 

Concerning the performance, if you wanted to make it more readable that would end under a List of Enum ZoneId, which is far bigger to exploit/edit than a simple int.

Edited by Tryskell
  • 0
Posted

fak is hard to understand for me :D 

Example im entering clan hall zone.

character.setInsideZone(L2Character.ZONE_CLANHALL, true);

and clan hall is in town.

character.setInsideZone(L2Character.ZONE_PEACE, true);

 

now  by checking in what zones im are result is: ZONE_PEACE, ZONE_CLANHALL, ZONE_MULTIFUNCTION, ZONE_GRAND (why this zones are in list?)

  • 0
Posted (edited)
41 minutes ago, wongerlt said:

fak is hard to understand for me :D 

Example im entering clan hall zone.

character.setInsideZone(L2Character.ZONE_CLANHALL, true);

and clan hall is in town.

character.setInsideZone(L2Character.ZONE_PEACE, true);

 

now  by checking in what zones im are result is: ZONE_PEACE, ZONE_CLANHALL, ZONE_MULTIFUNCTION, ZONE_GRAND (why this zones are in list?)

because you have wrong values in those zones.

 

you have to double their value from the previous one.

since the ZONE_NOSTORE = 32768 , the ZONE_MULTIFUNCTION must be ZONE_NOSTORE*2 .. 

32768*2=65536

public static final int ZONE_MULTIFUNCTION = 65536;
public static final int ZONE_GRAND = 131072;

 

zone grand = multifunction * 2

 

and the next one will be zone_grand * 2 = 262144

Edited by melron
  • Thanks 1
  • 0
Posted (edited)
16 minutes ago, wongerlt said:

and i do it, but how i make mistake with calculator , idk :D

Thanks now work.

just a wrong move at your calcs nothing serious :p

Edited by melron
Guest
This topic is now closed to further replies.


  • Posts

    • ElmoreLab Harbor - Eternal C1 x1: ✅ https://harbor.elmorelab.com ElmoreLab Harbor - Eternal C1 x1 - is an exclusive server of the Eternal C1 chronicles from the top project ElmoreLab Harbor.   A unique server of its kind, on which everyone will have maximum pleasure, such as oldschool players who dream of nostalgia and to feel the warmest and classic C1 chronicles, as well as experienced players who are tired of thousands unbalanced servers of late chronicles. Due to the professional corrections of the balance system and the HONEST gameplay system - on this server, EVERY player will feel like in their own, warm and cozy Harbor C1. Let's return to the origins of L2 - back to 2004 in C1! ❤️   ⭐ Server characteristics:   STRICTLY 1 window, NO BOXES Bans for RMT and bots/cheats No donations with benefits Unique and high-quality PTS-build from Master Toma Professional corrections and full class-balance Reworked economy and closed all abuses Improved animations and all aspects of the game Exclusive HD-client with high-quality textures Experienced administration and management Fixed all bugs, geodata, exploits and holes Maximum sociality due to the 1-box system Discovering, exploring and researching Big online International server Nostalgia and oldschool-feelings   Rates: x1 Server start: 14.02.2025   The server is at the final stages of development and preparation for release. Information on the server will be updated, soon the patchnotes and changes/edits will be posted. Don't miss the legendary and epic experience on the best server in the last 20 years! ❤️ Join our C1-forum with a lot of information about server and active discussions.   ⭐ Website: https://harbor.elmorelab.com   ✅ Forum: https://forum-harbor.elmorelab.com   💥 Telegram: https://t.me/l2harbor https://t.me/l2harbor_chat   ⚡ Discord: https://discord.gg/harborelmorelab
    • yeah ok, if you say what is fuctional 100% i can't say something different 😛  but if someone find hard to compile it or get vs and all that things i have here one more simple way here to put overlay in your own server or to change your window name with few money.
    • I've been using this for 2 years now with no issues from Discord. I don't use ogg.dll either. This one works with any l2.exe too; I don’t see any difference between them.
    • hmm.. ok i just see that, is different code first of all. My sources is totally different based in other way, with else libraries.  I have access to modify everything even to make the clock to stop show how many time users play in server. 1) so maybe keep some personal info more hide. 2) i dont use ogg.dll 3) i create it and give it ready + support to install it. Plus what is mine can working with what ever .exe you want not just l2 with same simple method. And i am sure if you try this source to compile it, after 3 hours discord will like shadowban your API too thats my source
  • Topics

×
×
  • Create New...