Development > Coding

Refractory of employee-structure

(1/2) > >>

Hoehrer:
I'm currently brainstorming about the implemention of advanced research and production functionality for UFO:AI. For that we need more information on hte location, skill and type of people that you (your company) employs.
For that i thought about a structure similar to the follwing:

New Header Information

--- Code: ---
#define MAX_EMPLOYEES 1024
#define MAX_EMPLOYEES_IN_BUILDING 64
// TODO:
// MAX_EMPLOYEES_IN_BUILDING should be redefined by a config variable that is lab/workshop/quaters-specific
// e.g.:
// if ( !maxEmployeesInQuater ) maxEmployeesInQuater = MAX_EMPLOYEES_IN_BUILDING;
// if ( !maxEmployeesWorkersInLab ) maxEmployeesWorkersInLab = MAX_EMPLOYEES_IN_BUILDING;
// if ( !maxEmployeesInWorkshop ) maxEmployeesInWorkshop = MAX_EMPLOYEES_IN_BUILDING;

// The definition of a employee
typedef struct employee_s
{
byte isWorker;
byte isScientist;
byte isSoldier;

char speed; // Speed of this Worker/Scientist at research/construction.

struct building_s *quaters; // The quater this employee is assigned to. (all)
struct building_s *lab; // The lab this scientist is working in. (only isScientist)
struct building_s *workshop; // The lab this worker is working in. (only isWorker)

struct character_s combat_stats; // Soldier stats (scis/workers as well ... e.g. if the base is attacked)
} employee_t;


// Struct to be used in building definition (-struct)
typedef struct employees_s
{
struct employee_s assigned[MAX_EMPLOYEES_IN_BUILDING];
int numEmployees;
int maxEmployees;
float cost_per_employee;
}

// This it the global list of scientists.
// Use this for saving and allocating.
extern employee_t employees[MAX_EMPLOYEES];
extern int numEmployees;

--- End code ---


EDIT of client.h

--- Code: ---
typedef struct building_s
{
...

// removed maxWorkers, minWorkers and  assignedWorkers

// ADDED
// A list of employees assigned to this building.
struct employee_s assigned_employees;


...
} building_t;

--- End code ---


I don't get what (exactly)some values in building_s are for though:
* workerCosts
* produceTime
* fixCosts
* varCosts
I can guess some of them, but i'm not 100% sure.


Mind you that i didn't include alot of information about soldiers (e.g training-room, injured, etc..) sicne this is just a first draft to make it all work with research/production, not combat.

What do you think? Questions, comments, critics?
   
Werner

Mattn:
* workerCosts <----- costs for each worker (they will get paid, too)  (not used nor implemented)
* produceTime <----- who much time for one unit of production type (not used nor implemented)
* fixCosts <---- costs for building
* varCosts  <---- costs for running and using a building. a lab will produce costs e.g.  (not used nor implemented??)

Mattn:
the structure itself looks reasonable.


--- Code: ---
typedef enum
{
  EMPL_WORKER;
  EMPL_SCIENTIST;
  EMPL_SOLDIER;
...
...
...
  MAX_EMPL; // for counting over all available enums
}
employeeType_t;

--- End code ---



--- Code: ---
   byte   isWorker;
   byte   isScientist;
   byte   isSoldier;
.....
  employeeType_t type

--- End code ---

Hoehrer:

--- Quote from: "Mattn" ---* workerCosts <----- costs for each worker (they will get paid, too)  (not used nor implemented)
* produceTime <----- who much time for one unit of production type (not used nor implemented)
* fixCosts <---- costs for building
* varCosts  <---- costs for running and using a building. a lab will produce costs e.g.  (not used nor implemented??)
--- End quote ---


Ah, exactly as i assumed. So workerCosts and produceTime wil most probably be moved to the employee_s as well (produceTime indirectly over "speed")

Werner

Hoehrer:

--- Quote from: "Mattn" ---the structure itself looks reasonable.


--- Code: ---
typedef enum
{
  EMPL_WORKER;
  EMPL_SCIENTIST;
  EMPL_SOLDIER;
...
...
...
  MAX_EMPL; // for counting over all available enums
}
employeeType_t;

--- End code ---



--- Code: ---
   byte   isWorker;
   byte   isScientist;
   byte   isSoldier;
.....
  employeeType_t type

--- End code ---

--- End quote ---


I'm not quite sure if i udnerstand you right.
1 Replacing isXxxxx with enums is ok with me (planned it with enums, but i just left the isXxxxx for now)
2 What i don't understand is what MAX_EMPL should be for
3 Why do you list the isXxxx _and_ the employeeType_t at the sdame time in the second code snippet?

EDIT if you want to use the MAX_EMPL as a termination flag, that's what the "int numEmployees" is for.

Werner

Navigation

[0] Message Index

[#] Next page

Go to full version