2007-06-28 10:47:08 -07:00
|
|
|
// ////////////////////////////////////////////////////////////////////////
|
|
|
|
// Includes
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/framework/frame.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "netplay.h"
|
2006-04-08 12:14:30 -07:00
|
|
|
#include "netlog.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
// ////////////////////////////////////////////////////////////////////////
|
|
|
|
// Logging for degug only
|
|
|
|
// ////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static FILE *pFileHandle;
|
|
|
|
|
|
|
|
BOOL NETstartLogging()
|
|
|
|
{
|
|
|
|
time_t aclock;
|
|
|
|
struct tm *newtime;
|
2006-06-02 12:34:58 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
time( &aclock ); /* Get time in seconds */
|
2006-04-08 12:14:30 -07:00
|
|
|
newtime = localtime( &aclock ); /* Convert time to struct */
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-04-08 12:14:30 -07:00
|
|
|
pFileHandle = fopen("netplay.log", "w"); // open the file
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!pFileHandle)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
fprintf(pFileHandle,"NETPLAY log: %s\n",asctime( newtime ) );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL NETstopLogging()
|
2006-06-02 12:34:58 -07:00
|
|
|
{
|
2007-06-28 10:47:08 -07:00
|
|
|
if (fclose(pFileHandle) != 0)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL NETlogEntry(CHAR *str,UDWORD a,UDWORD b)
|
|
|
|
{
|
|
|
|
static UDWORD lastframe = 0;
|
|
|
|
UDWORD frame= frameGetFrameNumber();
|
|
|
|
time_t aclock;
|
|
|
|
struct tm *newtime;
|
|
|
|
|
|
|
|
#ifndef MASSIVELOGS
|
|
|
|
if(a ==9 || a==10)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
2006-06-02 12:34:58 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
time( &aclock ); /* Get time in seconds */
|
|
|
|
newtime = localtime( &aclock ); /* Convert time to struct */
|
|
|
|
|
|
|
|
// check to see if a new frame.
|
|
|
|
if(frame != lastframe)
|
|
|
|
{
|
|
|
|
lastframe = frame;
|
|
|
|
fprintf(pFileHandle,"-----------------------------------------------------------\n");
|
2006-06-02 12:34:58 -07:00
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
switch(a) // replace common msgs with txt descriptions
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_DROIDINFO \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_DROIDDEST \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_DROIDMOVE \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_GROUPORDER \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_PING \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_CHECK_DROID \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_CHECK_STRUCT \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_CHECK_POWER \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_BUILD \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_BUILDFINISHED \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 17:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_TXTMSG \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 18:
|
|
|
|
fprintf(pFileHandle,"************************************************************\n");
|
2006-04-08 12:14:30 -07:00
|
|
|
fprintf(pFileHandle,"%s \t: NET_LEAVING \t:%d\t\t%s",str,b,asctime( newtime ));
|
2007-06-28 10:47:08 -07:00
|
|
|
fprintf(pFileHandle,"************************************************************\n");
|
|
|
|
break;
|
|
|
|
case 19:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_REQUESTDROID \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 23:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_WHOLEDROID \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 22:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_STRUCT (Whole) \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 25:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_PLAYERRESPONDING \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 26:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_OPTIONS \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 27:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_WAYPOINT \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 28:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_SECONDARY \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 29:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_FIREUP \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 34:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_ARTIFACTS \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 36:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_SCORESUBMIT \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 37:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_DESTROYXTRA \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 38:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_VTOL \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
case 39:
|
|
|
|
fprintf(pFileHandle,"%s \t: NET_VTOLREARM \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
fprintf(pFileHandle,"%s \t:%d \t\t\t:%d\t\t%s",str,a,b,asctime( newtime ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fflush(pFileHandle);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ////////////////////////////////////////////////////////////////////////
|