EOSERV Forum > EOSERV > What does If->this->character refer to in EOSERV code?
Page: << 1 >>
What does If->this->character refer to in EOSERV code?
Author Message
Post #201689 What does If->this->character refer to in EOSERV code?

I'm wondering what "this" is? Where is "this" defined?

7 years, 20 weeks ago
Post #201690 Re: What does If->this->character refer to in EOSERV code?

"this" is a C++ term used to describe the object which the function in question is a member of.


Oh, and "this" refers to the EOClient object in the packet handlers.

---
Want to learn to pixel?
Pixelsource.org
7 years, 20 weeks ago
Post #201691 Re: What does If->this->character refer to in EOSERV code?

"this" returns a pointer to the object calling the function .

You can call class members directly without it , however if you have a local variable declared in the function definition , if this local variable have the same name of a class member using "this" essential because without it you are refering to the local variable.

7 years, 20 weeks ago
Post #201696 Re: What does If->this->character refer to in EOSERV code?

To explain as simply as possible, "this" is the root pointer for a current object of a given class. For the sake of EOSERV use, you will see this used for various things. In character.cpp, the current referenced character is "this" and all pointers are members of the character class as defined in character.hpp. The same is true for other classes such as maps, npc, client, etc. So basically this is a class object that points to member variables of functions within its class. 

7 years, 20 weeks ago
Post #201712 Re: What does If->this->character refer to in EOSERV code?

If I were to break this down into non-tech/code words and if I were to probably be more than likely wrong, then this is what I got for you:


Take "If->this->character" for example.

Now imagine you had a bowl full of Fruit and Vegetables. This is your EOSERV.

Now imagine a person is approaching this bowl and was going to do something with it. Anything at all. Kick it. Fuck it. Eat it. Smash it. Etc. That's your "if".

Now imagine a person picked up a fruit/veg; but what fruit? What Veg? Which one is it? Who knows? Who cares? He picked something up. The fruit or veg is your "this".

Now imagine this person picked up a fruit. An apple, for example. This, right here, is your character.


I am so goddamn wrong lmao

---
"Nurd, you're like a fucking swiss army knife" - Necrosis
7 years, 20 weeks ago
Post #201715 Re: What does If->this->character refer to in EOSERV code?
Nurd posted: (9th Dec 2016, 02:07 am)

If I were to break this down into non-tech/code words and if I were to probably be more than likely wrong, then this is what I got for you:


Take "If->this->character" for example.

Now imagine you had a bowl full of Fruit and Vegetables. This is your EOSERV.

Now imagine a person is approaching this bowl and was going to do something with it. Anything at all. Kick it. Fuck it. Eat it. Smash it. Etc. That's your "if".

Now imagine a person picked up a fruit/veg; but what fruit? What Veg? Which one is it? Who knows? Who cares? He picked something up. The fruit or veg is your "this".

Now imagine this person picked up a fruit. An apple, for example. This, right here, is your character.


I am so goddamn wrong lmao


Not quite - But to be fair, it should actually be "if (this->character)" - And unless it's just a check to see if the character exists, this too should probably be something else. He kind of mangled C++ syntax here.


So ignore the if. But in your metaphor, "this" would be the bowl of fruit, and the apple would be "character." The bowl of fruit has a member variable called "apple", to which this syntax is referring.

if (this->apple->color == COLOR_RED)
       Console::Out("Eat your fruit, Josh.");
else
       Console::Out("Eat shit, Josh.");

---
Want to learn to pixel?
Pixelsource.org
7 years, 20 weeks ago
Post #201723 Re: What does If->this->character refer to in EOSERV code?

Advice , do not listen to any other replies  besides mine's and apollo's .

You guys could get people infertile with your stupid jokes.

7 years, 20 weeks ago
Post #201729 Re: What does If->this->character refer to in EOSERV code?
freezingsoul posted: (9th Dec 2016, 05:08 pm)

Advice , do not listen to any other replies  besides mine's and apollo's .

You guys could get people infertile with your stupid jokes.


Careful guys, don't get infertile.
---
Want to learn to pixel?
Pixelsource.org
7 years, 19 weeks ago
Page: << 1 >>

EOSERV Forum > EOSERV > What does If->this->character refer to in EOSERV code?