project-navigation
Personal tools

Author Topic: Refractory of employee-structure  (Read 5666 times)

Hoehrer

  • Guest
Refractory of employee-structure
« on: March 30, 2006, 08:36:08 pm »
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: [Select]

#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;


EDIT of client.h
Code: [Select]

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;


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

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Refractory of employee-structure
« Reply #1 on: March 30, 2006, 09:19:26 pm »
* 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??)

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Refractory of employee-structure
« Reply #2 on: March 30, 2006, 09:22:55 pm »
the structure itself looks reasonable.

Code: [Select]

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


Code: [Select]

   byte   isWorker;
   byte   isScientist;
   byte   isSoldier;
.....
  employeeType_t type

Hoehrer

  • Guest
Refractory of employee-structure
« Reply #3 on: March 30, 2006, 09:30:37 pm »
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??)


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

  • Guest
Refractory of employee-structure
« Reply #4 on: March 30, 2006, 09:34:27 pm »
Quote from: "Mattn"
the structure itself looks reasonable.

Code: [Select]

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


Code: [Select]

   byte   isWorker;
   byte   isScientist;
   byte   isSoldier;
.....
  employeeType_t type


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

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Refractory of employee-structure
« Reply #5 on: March 30, 2006, 09:53:22 pm »
the is.... stuff away and the enum in its place

the last one if for something like this
Code: [Select]

for ( i = 0; i < MAX_EMPL; i++ )
{
 // this way you can add new employeeTypes without changing your code.
 // but if you are planning to use switch only you maybe don't need this.
}


the numEmployees is only for parsed or assigned workers/soldiers imo, don't it? this are two different cases.

do you understand what i mean?

Hoehrer

  • Guest
Refractory of employee-structure
« Reply #6 on: March 30, 2006, 10:07:50 pm »
Quote from: "Mattn"
the is.... stuff away and the enum in its place

Ok, as i though.

Quote
the last one if for something like this
Code: [Select]

for ( i = 0; i < MAX_EMPL; i++ )
{
 // this way you can add new employeeTypes without changing your code.
 // but if you are planning to use switch only you maybe don't need this.
}

Actually i'm not sure i understand it, except if "i=0" equals "i= FirstEnum", but then i still need to check what type it is in the end -> "if" or "switch".

Quote
the numEmployees is only for parsed or assigned workers/soldiers imo, don't it? this are two different cases.

That's what i planned. I don't think we will get more employeeTypes than maybe 4 or 5 (workers, scientists, soldiers, robots, medics).

Werner