mux/src/svdreport.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include "attrs.h"
#include "command.h"

Include dependency graph for svdreport.cpp:

Go to the source code of this file.

Defines

#define NPERIODS   24

Functions

void do_report (dbref executor, dbref caller, dbref enactor, int extra)


Define Documentation

#define NPERIODS   24

Definition at line 17 of file svdreport.cpp.

Referenced by do_report().


Function Documentation

void do_report ( dbref  executor,
dbref  caller,
dbref  enactor,
int  extra 
)

Definition at line 18 of file svdreport.cpp.

References A_LAST, alloc_mbuf, atr_get, DO_WHOLE_DB, free_lbuf, free_mbuf, CLinearTimeAbsolute::GetLocal(), isPlayer, notify, NPERIODS, CLinearTimeAbsolute::SetString(), and UNUSED_PARAMETER.

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 }


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