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>
|
2006-06-21 10:15:18 -07:00
|
|
|
#include <physfs.h>
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// ////////////////////////////////////////////////////////////////////////
|
|
|
|
// Logging for degug only
|
|
|
|
// ////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-06-21 10:15:18 -07:00
|
|
|
static PHYSFS_file *pFileHandle;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
BOOL NETstartLogging()
|
|
|
|
{
|
|
|
|
time_t aclock;
|
|
|
|
struct tm *newtime;
|
2006-06-21 10:15:18 -07:00
|
|
|
char buf[256];
|
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-06-21 10:15:18 -07:00
|
|
|
pFileHandle = PHYSFS_openWrite( "netplay.log" ); // open the file
|
2007-06-28 10:47:08 -07:00
|
|
|
if (!pFileHandle)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "NETPLAY log: %s\n", asctime( newtime ) );
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL NETstopLogging()
|
2006-06-02 12:34:58 -07:00
|
|
|
{
|
2006-06-21 10:15:18 -07:00
|
|
|
if (PHYSFS_close(pFileHandle) != 0)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
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;
|
2006-06-21 10:15:18 -07:00
|
|
|
char buf[256];
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
#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;
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "-----------------------------------------------------------\n" );
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
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:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_DROIDINFO \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 2:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_DROIDDEST \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 3:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_DROIDMOVE \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 4:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_GROUPORDER \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 8:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_PING \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 9:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_CHECK_DROID \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 10:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_CHECK_STRUCT \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 11:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_CHECK_POWER \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 13:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_BUILD \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 15:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_BUILDFINISHED \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 17:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_TXTMSG \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 18:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "************************************************************\n");
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
|
|
|
sprintf( buf, "%s \t: NET_LEAVING \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
|
|
|
sprintf( buf, "************************************************************\n");
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 19:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_REQUESTDROID \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 23:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_WHOLEDROID \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 22:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_STRUCT (Whole) \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 25:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_PLAYERRESPONDING \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 26:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_OPTIONS \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 27:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_WAYPOINT \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 28:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_SECONDARY \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 29:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_FIREUP \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 34:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_ARTIFACTS \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 36:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_SCORESUBMIT \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 37:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_DESTROYXTRA \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 38:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_VTOL \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
case 39:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t: NET_VTOLREARM \t:%d\t\t%s",str,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-06-21 10:15:18 -07:00
|
|
|
sprintf( buf, "%s \t:%d \t\t\t:%d\t\t%s",str,a,b,asctime( newtime ));
|
|
|
|
PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
}
|
2006-06-21 10:15:18 -07:00
|
|
|
PHYSFS_flush(pFileHandle);
|
2007-06-28 10:47:08 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ////////////////////////////////////////////////////////////////////////
|