1

Topic: A line that I don't understand

Hello!

I don't understand this line (in player.cpp) :

m_pCharacter = new(m_ClientID) CCharacter(&GameServer()->m_World);

I tried searching/asking to people what it does, but I couldn't get an answer.

What I'm exactly talking about is new(m_ClientID).

while(!Success())
    TryAgain();
Try until you succeed.

2

Re: A line that I don't understand

Seems to be coming down to a custom new operator and dynamic memory handling.

in character.cpp, right above the constructor
MACRO_ALLOC_POOL_ID_IMPL(CCharacter, MAX_CLIENTS)

in entity.h
#define MACRO_ALLOC_POOL_ID_IMPL(POOLTYPE, PoolSize) \
    static char ms_PoolData##POOLTYPE[PoolSize][sizeof(POOLTYPE)] = {{0}}; \
    static int ms_PoolUsed##POOLTYPE[PoolSize] = {0}; \
    void *POOLTYPE::operator new(size_t Size, int id) \
    { \
        dbg_assert(sizeof(POOLTYPE) == Size, "size error"); \
        dbg_assert(!ms_PoolUsed##POOLTYPE[id], "already used"); \
        /*dbg_msg("pool", "++ %s %d", #POOLTYPE, id);*/ \
        ms_PoolUsed##POOLTYPE[id] = 1; \
        mem_zero(ms_PoolData##POOLTYPE[id], Size); \
        return ms_PoolData##POOLTYPE[id]; \
    } \

3

Re: A line that I don't understand

Thank you Siile! smile

I asked a few more details to my teacher and he explained me that when you overload the new operator, it always takes a size_t as first parameter. This is what was confusing me.

while(!Success())
    TryAgain();
Try until you succeed.

4

Re: A line that I don't understand

Neox wrote:

Thank you Siile! smile

I asked a few more details to my teacher and he explained me that when you overload the new operator, it always takes a size_t as first parameter. This is what was confusing me.

Upload your server please

Hello, I need help, how can I create a mod?

5

Re: A line that I don't understand

I think you should upload your sources for legitimate helping purposes.

privet

6

Re: A line that I don't understand

Netherland wrote:

I think you should upload your sources for legitimate helping purposes.

My Monster mod is already opensource sir. smile

while(!Success())
    TryAgain();
Try until you succeed.

7

Re: A line that I don't understand

Neox wrote:
Netherland wrote:

I think you should upload your sources for legitimate helping purposes.

My Monster mod is already opensource sir. smile


Hello, someone help me create a mod, please I need to be taught

Hello, I need help, how can I create a mod?

8

Re: A line that I don't understand

4TB|Daniel wrote:
Neox wrote:
Netherland wrote:

I think you should upload your sources for legitimate helping purposes.

My Monster mod is already opensource sir. smile


Hello, someone help me create a mod, please I need to be taught

Learn C and C++ (C first)

while(!Success())
    TryAgain();
Try until you succeed.

9 (edited by 4TB|Daniel 2017-03-12 04:32:48)

Re: A line that I don't understand

Neox wrote:
4TB|Daniel wrote:
Neox wrote:

My Monster mod is already opensource sir. smile


Hello, someone help me create a mod, please I need to be taught

Learn C and C++ (C first)

And so?

Now that I start, I do not understand.

Hello, I need help, how can I create a mod?

10

Re: A line that I don't understand

4TB|Daniel wrote:
Neox wrote:
4TB|Daniel wrote:

Hello, someone help me create a mod, please I need to be taught

Learn C and C++ (C first)

And so?

Now that I start, I do not understand.

You'd need more than one day to learn that.

Not Luck, Just Magic.

11

Re: A line that I don't understand

Dune wrote:
4TB|Daniel wrote:
Neox wrote:

Learn C and C++ (C first)

And so?

Now that I start, I do not understand.

You'd need more than one day to learn that.

Who could make a youtube video of how to make a basic mod.

Hello, I need help, how can I create a mod?

12 (edited by Neox 2017-03-12 15:13:05)

Re: A line that I don't understand

Can you close this topic please? smile

while(!Success())
    TryAgain();
Try until you succeed.