mux/src/svdreport.cpp

Go to the documentation of this file.
00001 // svdreport.cpp -- Aggregate User Statistics module.
00002 //
00003 // $Id: svdreport.cpp,v 1.6 2006/01/07 07:39:04 sdennis Exp $
00004 //
00005 // MUX 2.4
00006 // Copyright (C) 1998 through 2004 Solid Vertical Domains, Ltd. All
00007 // rights not explicitly given are reserved.
00008 //
00009 #include "copyright.h"
00010 #include "autoconf.h"
00011 #include "config.h"
00012 #include "externs.h"
00013 
00014 #include "attrs.h"
00015 #include "command.h"
00016 
00017 #define NPERIODS 24
00018 void do_report(dbref executor, dbref caller, dbref enactor, int extra)
00019 {
00020     UNUSED_PARAMETER(caller);
00021     UNUSED_PARAMETER(enactor);
00022     UNUSED_PARAMETER(extra);
00023 
00024     char *buff = alloc_mbuf("do_report");
00025     int nBin[NPERIODS];
00026     int i;
00027 
00028     for (i = 0; i < NPERIODS; i++)
00029     {
00030         nBin[i] = 0;
00031     }
00032 
00033     CLinearTimeAbsolute ltaNow, ltaPlayer;
00034     ltaNow.GetLocal();
00035 
00036     const int PeriodInSeconds = 28800;
00037 
00038     int iPlayer;
00039     DO_WHOLE_DB(iPlayer)
00040     {
00041         if (isPlayer(iPlayer))
00042         {
00043             int aowner, aflags;
00044             char *player_last = atr_get(iPlayer, A_LAST, &aowner, &aflags);
00045 
00046             if (ltaPlayer.SetString(player_last))
00047             {
00048                 CLinearTimeDelta ltd(ltaPlayer, ltaNow);
00049                 int ltdSeconds = ltd.ReturnSeconds();
00050                 int iBin = ltdSeconds / PeriodInSeconds;
00051                 if (0 <= iBin && iBin < NPERIODS)
00052                 {
00053                     nBin[iBin]++;
00054                 }
00055             }
00056             free_lbuf(player_last);
00057         }
00058     }
00059 
00060     int iHour, nSum = 0;
00061     notify(executor, "Day   Hours     Players  Total");
00062     for (i = 0, iHour = 0; i < NPERIODS; i++, iHour += 8)
00063     {
00064         nSum += nBin[i];
00065         sprintf(buff, "%3d %03d - %03d: %6d %6d", iHour/24 + 1, iHour, iHour+8, nBin[i], nSum);
00066         notify(executor, buff);
00067     }
00068     free_mbuf(buff);
00069 }
00070 

Generated on Mon May 28 04:40:11 2007 for MUX by  doxygen 1.4.7