Page 1 of 1

Question about source--CPIFirstLogin::Handle

Posted: Tue Aug 10, 2004 8:27 pm
by Artomegus
I admit there are still many things about C++ that I don't quite have a handle on yet. I'm trying to understand what's going on in this section of code, so please pardon me if I sound ignorant.

At the beginning of CPIFirstLogin::Handle (in CPacketReceive.cpp), there is a declaration of a local ACCOUNTSBLOCK structure:

Code: Select all

ACCOUNTSBLOCK actbTemp;
It is populated with a call to Accounts->GetAccountByName

Later on, the wFlags member of this structure is modified. However, after that, it appears that the contents of the structure are never written back anywhere:

Code: Select all

...
		actbTemp.wFlags |= AB_FLAGS_ONLINE;

		UI16 servcount = cwmWorldState->ServerData()->ServerCount();
		CPGameServerList toSend( servcount );
		for( UI16 i = 0; i < servcount; ++i )
		{
			physicalServer *sData = cwmWorldState->ServerData()->ServerEntry( i );
			toSend.AddServer( i, sData );
		}
		tSock->Send( &toSend );
	}
	CPEnableClientFeatures ii;
	tSock->Send( &ii );
	return true;
Is there some kind of C++ magic going on that I don't understand or is this something that just hasn't been implemented yet?

Thanks for the help!

...Artomegus

Posted: Wed Aug 11, 2004 3:00 am
by Maarc
Your grasp of C++ is perfectly fine. This is an issue we've noticed (I think it's gotten mention in the changelogs). Unfortunately, we're making *copies* of the accountsblock structure, not altering references or pointers. We even have something #define'd that allows us to see the naughtiness.

If you head into Config.h, look at the bottom, you'll see something like this:

Code: Select all

#define _NOACTCOPY_ 0
Change it to

Code: Select all

#define _NOACTCOPY_ 1
and recompile, and watch the errors flow!

Why we're making copies and not using references/pointers I don't know. I've been meaning to look at it for a while, I just haven't had the time. But I think some of our account related problems would disappear if we properly used pointers or references.

Hope that's of help to you.

Posted: Sat Aug 14, 2004 6:50 am
by giwo
I've done some work to fix this sort of thing.... but still more to be done.

Whatever the case, what has been accomplished will be in my latest which will probably be out tomorrow or sunday.