Question about source--CPIFirstLogin::Handle

Forum where anything UOX3-related goes - including, but not limited to: newbie-support, ideas, general questions, comments, etc and-so-forth.
Post Reply
Artomegus
UOX3 Newbie
Posts: 1
Joined: Tue Aug 10, 2004 7:57 pm
Has thanked: 0
Been thanked: 0

Question about source--CPIFirstLogin::Handle

Post 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
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post 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.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post 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.
Scott
Post Reply