Code:
void CClient::addGumpDialogAdmin( int iAdPage, int iSortType )
{
// Alter this routine at your own risk....if anymore
// bytes get sent to the client, you WILL crash them
// Take away, but don't add (heh) (actually there's like
// 100 bytes available, but they get eaten up fast with
// this gump stuff)
static LPCTSTR const sm_szGumps = // These are on every page and don't change
{
"page 0",
"resizepic 0 0 5120 623 310",
"resizepic 242 262 5120 170 35",
"text 230 10 955 0",
};
CGString sControls;
int iControls = 0;
while ( iControls<COUNTOF(sm_szGumps))
{
sControls = sm_szGumps;
iControls++;
}
CGString sText;
int iTexts=1;
sText.Format( "Admin Control Panel (%d clients)", g_Serv.m_Clients.GetCount());
static const int sm_iColSpaces = // These are on every page and don't change
{
8 + 19, // Text (sock)
8 + 73, // Text (account name)
8 + 188, // Text (name)
8 + 328, // Text (ip)
8 + 474 // Text (location)
};
static LPCTSTR const sm_szColText = // These are on every page and don't change
{
"Sock",
"Account",
"Name",
"IP Address",
"Location"
};
while ( iTexts<=COUNTOF(sm_szColText) )
{
sControls.Format( "text %d 30 955 %d", sm_iColSpaces-2, iTexts );
iControls++;
sText = sm_szColText;
iTexts++;
}
// Count clients to show.
// Create sorted list.
CClientSortList ClientList;
ClientList.SortByType( 1, m_pChar );
// none left to display for this page ?
int iClient = iAdPage*ADMIN_CLIENTS_PER_PAGE;
if ( iClient >= ClientList.GetCount())
{
iAdPage = 0; // just go back to first page.
iClient = 0;
}
m_tmGumpAdmin.m_iPageNum = iAdPage;
m_tmGumpAdmin.m_iSortType = iSortType;
int iY = 50;
for ( int i=0; iClient<ClientList.GetCount() && i<ADMIN_CLIENTS_PER_PAGE; iClient++, i++ )
{
CClient * pClient = ClientList.GetAt(iClient);
ASSERT(pClient);
// Sock buttons
// X, Y, Down gump, Up gump, pressable, iPage, id
sControls.Format(
"button 12 %i 2362 2361 1 1 %i",
iY + 4, // Y
901 + i ); // id
for ( int j=0; j<COUNTOF(sm_iColSpaces); j++ )
{
sControls.Format(
"text %i %i 955 %i",
sm_iColSpaces,
iY,
iTexts+j );
}
CSocketAddress PeerName = pClient->m_Socket.GetPeerName();
TCHAR accountName;
strcpylen( accountName, pClient->GetName(), 12 );
// max name size for this dialog....otherwise CRASH!!!, not a big enuf buffer :(
CChar * pChar = pClient->GetChar();
if ( pClient->IsPriv(PRIV_GM) || pClient->GetPrivLevel() >= PLEVEL_Counsel )
{
memmove( accountName+1, accountName, 13 );
accountName = ( pChar && pChar->IsDND()) ? '*' : '+';
}
ASSERT( i<COUNTOF(m_tmGumpAdmin.m_Item));
if ( pChar != NULL )
{
m_tmGumpAdmin.m_Item = pChar->GetUID();
TCHAR characterName;
strcpy(characterName, pChar->GetName());
characterName = 0; // same comment as the accountName...careful with this stuff!
sText.Format("%x", pClient->m_Socket.GetSocket());
sText = accountName;
sText = characterName;
CPointMap pt = pChar->GetTopPoint();
sText.Format( "%s", PeerName.GetAddrStr()) ;
sText.Format( "%d,%d,%d ",
pt.m_x,
pt.m_y,
pt.m_z,
pt.m_mapplane) ;
}
else
{
m_tmGumpAdmin.m_Item = 0;
sText.Format( "%03x", pClient->m_Socket.GetSocket());
sText = accountName;
sText = "N/A";
sText = PeerName.GetAddrStr();
sText = "N/A";
}
iY += 20; // go down a 'line' on the dialog
}
if ( m_tmGumpAdmin.m_iPageNum ) // is there a previous ?
{
sControls = "button 253 267 5537 5539 1 0 801"; // p
}
if ( iClient<ClientList.GetCount()) // is there a next ?
{
sControls = "button 385 267 5540 5542 1 0 802"; // n
}
addGumpDialog( CLIMODE_DIALOG_ADMIN, sControls, iControls, sText, iTexts, 0x05, 0x46 );
}