UFO:Alien Invasion
Development => Coding => Topic started by: Hoehrer 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
#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
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
-
* 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??)
-
the structure itself looks reasonable.
typedef enum
{
EMPL_WORKER;
EMPL_SCIENTIST;
EMPL_SOLDIER;
...
...
...
MAX_EMPL; // for counting over all available enums
}
employeeType_t;
byte isWorker;
byte isScientist;
byte isSoldier;
.....
employeeType_t type
-
* 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
-
the structure itself looks reasonable.
typedef enum
{
EMPL_WORKER;
EMPL_SCIENTIST;
EMPL_SOLDIER;
...
...
...
MAX_EMPL; // for counting over all available enums
}
employeeType_t;
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
-
the is.... stuff away and the enum in its place
the last one if for something like this
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?
-
the is.... stuff away and the enum in its place
Ok, as i though.
the last one if for something like this
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".
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