Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:1342] James...



James, thanks for helping out with the stat testing earlier today.  We'll
need extensive testing once I can get the rest of the stuff merged in.
I talked to Tom for a while during the game, and he seemed eager to get
the new stats in, but not for this season.  I'm hoping that we can get
this stuff tested and bug-free for the summer season.

The below URL is for a prelim copy of a partial merge of what I have.
By partial, I mean that I'm reviewing and adding each section of code
at a time (and reimplementing some of the stuff as well) from the earlier
copies of the code.  At this point, I have about 1/2 of the changes in.

The URL is ftp://ftp.netrek.org/pub/netrek/servers/vanilla/private/
           Vanilla.merge.tar.gz

Anyone other than James, I don't recommend trying to download and compile
this thing.  They include a lot of stuff that is inappropriate for even
an alpha-level release.  But, those interested in the contents of the
new stats, I have attached a copy of the ntserv/ltd_stats.h file.  It
contains (up to this point) all the new stats that I discussed with
Leonard and Tom a while back.

A couple of notes about the tar file: ntserv, daemonII, newtartd and inl
(along with a few other binaries) will compile fine.  Most binaries in the
tools/ dir are broken.  XSG is broken.  If you go in and #undef LTD_STATS,
though, everything _should_ revert back to the current (today's) version
of the source in the CVS tree.  Please don't commit any of these files
into the main src trunk.

Currently, the only way to check whether the LTD stats are working is to
add an ltd_dump() after the write(playerstats)'s in daemonII.c and
getname.c.  That will save the player stats each time they quit out or
get kicked out.  I have not yet put in the keyword stat bounce stuff.

Aside from LTD stats, the other major thing you will notice is that much
of the code in the ntserv/ directory has been ANSIfied.  You should be
able to enable the equivalent of cc -ansi -fullwarn and get only a few
warnings.  In the process of ANSIfying, I fixed a number of programming
bugs throughout the source, because the errors became visible through
prototyping.

There are a couple of things I want to do: get rid of some of those
horrifying #ifdefs:
	CHAIN_REACTION, ERIKPLAGUE, FLAT_BONUS, NEW_CREDIT, BASEPRACTICE

and make those either a permanent part of the server code or configurable
via .sysdef.  All the #ifdef LTD_STATS is getting very excessive, and
I may just end up fragmenting the daemonII.c file into parts to make
it readable.

The messaging interface could use a cleanup.  The whole darned thing is
a mess.

There are redundant *cmds.* and commands.c right now.  I think we need to
get rid of the commands.c.

I also have a whole list of other (long term) comments about the INL
robot and the LTD stats, but I'm really tired atm, so I'll bounce
them to the list at a later time.

You know, I've noticed that I'm really rusty with C programming. :P

Dave
-- 
Dave Ahn <ahn@vec.wfubmc.edu>        |  "When you were born, you cried and the
                                     |  world rejoiced.  Try to live your life
Virtual Endoscopy Center             |  so that when you die, you will rejoice
Wake Forest Univ. School of Medicine |  and the world will cry."  -1/2 jj^2
/* $Id$
 *
 * Dave Ahn
 *
 * Leonard/Tom/Dave (LTD) Extended statistics.  For detailed info, read
 * the README.LTD file.
 *
 * For inline optimization details, read the README.LTD and
 * ltd_stats.c files.
 *
 * struct ltd_stats is a per-ship statistics group for each player.
 * This means that the player DB will increase by several factors in
 * size at the benefit of detailed stats that can be used to analyze
 * individual play for clued games.  The LTD stats can also be used on
 * a per-player basis by defining LTD_MERGED.
 * */

#ifndef __INCLUDED_ltd_stats_h__
#define __INCLUDED_ltd_stats_h__

#include "defs.h"	/* We need defines from this file */

/* XXNOTE: remove this before CVS checkin
   */

#define ARMYTRACK		/* DEBUGGING */

/* XXNOTE: these should be const enums
   */

#define LTD_TICK_ZONE_0		0	/* Zone 0 = backfield */
#define LTD_TICK_ZONE_1		1	/* Zone 1 = core + 2 open side */
#define LTD_TICK_ZONE_2		2	/* Zone 2 = front line */
#define LTD_TICK_ZONE_3		3	/* Zone 3 = enemy front line */
#define LTD_TICK_ZONE_4		4	/* Zone 4 = enemy core + 2 open side */
#define LTD_TICK_ZONE_5		5	/* Zone 5 = enemy backfield */
#define LTD_TICK_ZONE_6		6	/* Zone 6 = 3rd space */
#define LTD_TICK_ZONES		7	/* number of zones */

/* XXNOTE: find a better way to do the inlining
   */

#ifdef LTD_INLINE
#define __LTD_INLINE inline static
#else
#define __LTD_INLINE
#endif

#ifdef LTD_MERGED		/* for merged stats, we have one struct for
                                   non-SB and one struct for SB */

/* XXNOTE: these should be const enums
   */

#  define LTD_SC	0
#  define LTD_DD	0
#  define LTD_CA	0
#  define LTD_BB	0
#  define LTD_AS	0
#  define LTD_SB	1
#  define LTD_GA	0
#  define LTD_AT	0
#  define LTD_NUM_SHIPS	2

#else				/* for extende stats, one struct for each
                                   ship except GA and AT, which share the
                                   same slot */
#  define LTD_SC	0
#  define LTD_DD	1
#  define LTD_CA	2
#  define LTD_BB	3
#  define LTD_AS	4
#  define LTD_SB	5
#  define LTD_GA	6
#  define LTD_AT	6
#  define LTD_NUM_SHIPS	7

#endif

/* LTD stats structure */

struct ltd_stats {

  /* How many times have I killed in this ship */

  struct _kills {

    unsigned int total;			/* total number of kills ever */
    double max;				/* max kills ever achieved */
    unsigned int first;			/* number of first kills made */
    unsigned int first_potential;	/* first kills that could be
                                           converted to carries */
    unsigned int first_converted;	/* first kills that actually were
                                           converted to carries */
    unsigned int second;		/* number of second kills made */
    unsigned int second_potential;	/* second kills that could be
                                           converted to carries */
    unsigned int second_converted;	/* second kills that actually were
                                           converted to carries */
    unsigned int phasered;		/* number of kills made with a
                                           phaser death blow */
    unsigned int torped;		/* number of kills made with a
                                           torp blow */
    unsigned int plasmaed;		/* number of kills made with a
                                           plamsa */
  } kills;


  /* How many times have I died in this ship */

  struct _deaths {

    unsigned int total;			/* total number of deaths ever */
    unsigned int potential;		/* number of times died as a
                                           potential carrier */
    unsigned int converted;		/* number of times died as a
                                           a converted carrier */
    unsigned int dooshed;		/* number of times died while ++ */
    unsigned int phasered;		/* number of times died from phaser */
    unsigned int torped;		/* number of times died from torp */
    unsigned int plasmaed;		/* number of times died from plasma */
    unsigned int acc;			/* number of times you died, and
                                           someone picked up armies with
                                           the kill */

  } deaths;


  /* How many planets have I destroyed or taken */

  struct _planets {

    unsigned int taken;			/* number of planets taken */
    unsigned int destroyed;		/* number of planets destroyed */

  } planets;


  /* How many enemy armies have you bombed */

  struct _bomb {

    unsigned int planets;		/* number of planets bombed */
    unsigned int planets_8;		/* number of planets with <= 8
                                           armies bombed */
    unsigned int planets_core;		/* number of core planets bombed */
    unsigned int armies;		/* total number of armies bombed */
    unsigned int armies_8;		/* armies bombed where the planet
                                           being bombed had <= 8 armies */
    unsigned int armies_core;		/* armies bombed in a core planet */

  } bomb;


  /* How many enemy carriers have you killed and armies ogged */

  struct _ogged {

    unsigned int armies;		/* number of enemy armies ogged */
    unsigned int dooshed;		/* number of dooshed real carriers */
    unsigned int converted;		/* number of converted enemy
                                           carriers */
    unsigned int potential;		/* number of potential enemy
                                           carriers */
    unsigned int bigger_ship;		/* number of times a real carrier
                                           was in a bigger ship */
    unsigned int same_ship;		/* number of times a real carrier
                                           was in the same sized ship */
    unsigned int smaller_ship;		/* number of times a real carrier
                                           was in the same sized ship */
    unsigned int sb_armies;		/* number of armies on enemy SB
                                           ogged */
    unsigned int friendly;		/* number of friendly carriers
                                           you killed */
    unsigned int friendly_armies;	/* number of friendly armies you
                                           killed due to blatant stupidity */

  } ogged;


  /* How many friendly armies have you carried */

  struct _armies {

    unsigned int total;			/* number of friendly armies carried */
    unsigned int attack;		/* armies droped on enemy planets */
    unsigned int reinforce;		/* armies used to reinforce friendly
                                           planet < 4 */
    unsigned int ferries;		/* armies ferried to friendly planet
                                           >= 4 or SB */
    unsigned int killed;		/* armies killed */

  } armies;


  /* How many carries have you made */

  struct _carries {

    unsigned int total;			/* number of carries you attempted */
    unsigned int partial;		/* number of times you delivered
                                           at least 1 army before dying ++ */
    unsigned int completed;		/* number of times you completed
                                           your carry by delivering all
                                           the armies */
    unsigned int attack;		/* number of times you dropped on
                                           a neutral or enemy planet */
    unsigned int reinforce;		/* number of times you reinforced
                                           a friendly planet < 4 */
    unsigned int ferries;		/* number of times you ferried to
                                           a friendly planet >= 4 or SB */

  } carries;


  /* How much time we spent in relevant roles, modes or space */

  struct _ticks {

    unsigned int total;			/* total = green + yellow + red */
    /* unsigned int green; */		/* time spent in green alert */
    unsigned int yellow;		/* time spent in yellow alert */
    unsigned int red;			/* time spent in red alert */

    unsigned int zone[LTD_TICK_ZONES];	/* time spent in a particular zone */

    unsigned int potential;		/* time spent as potential carrier */
    unsigned int carrier;		/* time spent as carrier */
    unsigned int repair;		/* time spent in repair mode */

  } ticks;


  /* How far forward do spend most of your time */

  unsigned int offense;			/* absolute offense measured from
                                           distance to homeworld */

  unsigned int damage_repaired;		/* total damage repaired */


  /* Weapon stats */

  struct _weapons {

    /* phasers */

    struct _phaser {

      unsigned int fired;		/* number of times the weapon was
                                           fired */
      unsigned int hit;			/* number of times the weapon hit */

      struct _damage {

        unsigned int inflicted;		/* damage inflicted with this weapon */
        unsigned int taken;		/* damage taken from this weapon */

      } damage;

    } phaser;

    /* torps */

    struct _torp {

      unsigned int fired;		/* number of torps that were fired */
      unsigned int hit;			/* number of torps hit */
      unsigned int detted;		/* number of torps that were detted
                                           by enemy */
      unsigned int selfdetted;		/* number of torps self detted */
      unsigned int wall;		/* number of torps that hit the wall */

      struct _damage damage;		/* damage inflicted/taken */

    } torps;


    /* plasma */

    struct _plasma {

      unsigned int fired;		/* number of plasmas that were fired */
      unsigned int hit;			/* number that hit */
      unsigned int phasered;		/* number that were phasered */
      unsigned int wall;		/* number that hit the wall */

      struct _damage damage;		/* damage inflicted/taken */

    } plasma;

    /* damage repaired */

  } weapons;

};


/* LTD history structure - this is needed to calculate the LTD stats
   every tick. */

/* XXNOTE: /home/cecum/ahn/NT/old/Server.pl6/ntserv/struct.h
   pl6 has player.p_killlist, player.p_blah.  put it into ltd_history
   struct.
   */

struct ltd_history {
  int dummy_struct;
};


/* XXNOTE: /home/cecum/ahn/NT/old/Server.pl6/ntserv/struct.h
   copy struct session_stats here
   */

struct session_stats {
  int dummy_struct;
};



/* forward declarations of structs for function prototypes */

struct player;
struct stats;
struct planet;

/* function prototypes for non-inlined functions */

void ltd_reset(struct player *);
void ltd_reset_struct(struct ltd_stats *);
int ltd_meets_rank(struct player *, int);

/* XXNOTE: remove ltd_dump before CVS commit
   */

void ltd_dump(struct player *);

/* function prototypes for inlined functions */

__LTD_INLINE float ltd_total_rating(struct player *);
__LTD_INLINE float ltd_bombing_rating(struct player *);
__LTD_INLINE float ltd_planet_rating(struct player *);
__LTD_INLINE float ltd_defense_rating(struct player *);
__LTD_INLINE float ltd_offense_rating(struct player *);

__LTD_INLINE int ltd_total_kills(struct player *);
__LTD_INLINE int ltd_total_deaths(struct player *);
__LTD_INLINE int ltd_total_armies_bombed(struct player *);
__LTD_INLINE int ltd_total_planets_taken(struct player *);
__LTD_INLINE int ltd_total_ticks(struct player *);
__LTD_INLINE int ltd_total_kills_max(struct player *);

__LTD_INLINE void ltd_update_ticks(struct player *);
__LTD_INLINE void ltd_update_kills(struct player *credit_killer,
                                   struct player *actual_killer,
                                   struct player *victim);
__LTD_INLINE void ltd_update_kills_max(struct player *);
__LTD_INLINE void ltd_update_deaths(struct player *victim,
                                    struct player *actual_killer);
__LTD_INLINE void ltd_update_bomb(struct player *bomber,
                                  struct planet *planet_bombed,
                                  int armies_bombed);
__LTD_INLINE void ltd_update_planets(struct player *taker,
                                     struct planet *planet);
__LTD_INLINE void ltd_update_armies(struct player *carrier,
                                    struct planet *planet);
__LTD_INLINE void ltd_update_armies_carried(struct player *carrier,
                                            struct player *sb);
__LTD_INLINE void ltd_update_armies_ferried(struct player *carrier,
                                            struct player *sb);

__LTD_INLINE int ltd_sb_kills(struct player *);
__LTD_INLINE int ltd_sb_deaths(struct player *);
__LTD_INLINE int ltd_sb_ticks(struct player *);
__LTD_INLINE int ltd_sb_kills_max(struct player *);

/* XXNOTE: protos from older copy of src before being shelved.  these
   need to be reviewed and added here and into ltd_stats.c
   */

#include "/home/cecum/ahn/NT/old/Server.INL/ntserv/ltd_proto.h"
#include "/home/cecum/ahn/NT/old/Server.pl6/ntserv/ltd_session.h"

/* XXNOTE: find a better way to do this inline stuff */

#ifdef LTD_INLINE		/* this stuff is ugly */
#define __LTD_INCLUDE_SOURCE
#include "ltd_stats.c"
#undef  __LTD_INCLUDE_SOURCE
#endif

#endif /* __INCLUDED_ltd_stats_h__ */