//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose: Implementation of CCVarList
//
// $Workfile:     $
// $Date:         $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================
#include "cvars.h"

//------------------------------------------------------------------------------------------------------
// Function:	CCVarList::writeHTML
// Purpose:	generates and writes the report. generate() is not used in this object
// because there is no real intermediate data. Really data is just taken from the 
// event list, massaged abit, and written out to the html file. There is no calculation
// of stats or figures so no intermedidate data creation is needed.
// Input:	html - the html file that we want to write to. 
//------------------------------------------------------------------------------------------------------
void CCVarList::writeHTML(CHTMLFile& html)
{
	CEventListIterator it;
	html.write("<table border=0 width=100%% cols=%li><tr>\n",HTML_TABLE_NUM_COLS);
	bool startOfRow=true;
	for (it=g_pMatchInfo->eventList()->begin(); it != g_pMatchInfo->eventList()->end(); ++it)
	{
		if ((*it)->getType()==CLogEvent::CVAR_ASSIGN)
		{
			char var[100];
			char val[100];
			
			if (!(*it)->getArgument(0) || !(*it)->getArgument(1))
				return;

			(*it)->getArgument(0)->getStringValue(var);
			(*it)->getArgument(1)->getStringValue(val);
			

			//mask off any passwords that the server op may not want to be displayed
			if (stricmp(var,"rcon_password")==0 || stricmp(var,"sv_password")==0 || stricmp(var,"password")==0)
			{
				html.write("<!-- %s not shown! -->\n",var);
				continue;
			}

			if (startOfRow)
			{
				html.write("</tr>\n<tr>");
				startOfRow=false;
			}
			else
				startOfRow=true;

			html.write("\t<td><font class=cvar> %s = %s </font> </td>\n",var,val);
			
		}
	}
	html.write("</tr></table>");
}

