After moving all my functions to g_combat.c, I now get different undefined references:
-------------- Build: windows_debug in game ---------------
Compiling: ..\..\src\game\g_combat.c
Linking dynamic library: ..\..\base\game.dll
.objs\game\src\game\g_combat.o: In function `CL_ActorDamage':C:/cprogs/UFOAI-2.3-dev/src/game/g_combat.c:205: undefined reference to `LIST_AddPointer'
.objs\game\src\game\g_combat.o: In function `CL_ActorTreat':C:/cprogs/UFOAI-2.3-dev/src/game/g_combat.c:305: undefined reference to `LIST_GetByIdx'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 0 warnings
So, I've run into the problem that prevents me from adding this code to either cl_actor.c and g_combat.c.
I doubt it'll help any, but here is all the code I'm trying to compile... It is untested, and probably very buggy though, but here it is anyways:
/**
* @brief Damage the actor.
* @param[in] target Who is injured
* @param[in] damage How much damage is being inflicted
*/
void CL_ActorDamage (edict_t *target, const int damage)
{
wound_t *newWound;
int randomValue;
/**< Sanity check, don't add a wound if no damage was done. */
if(damage <= 0)
return;
newWound = malloc(sizeof(wound_t));
/**< First determine where the wound is */
randomValue = rand() % (WOUND_HEAD_PROBABILITY + WOUND_CHEST_PROBABILITY + WOUND_ARMS_PROBABILITY + WOUND_LEGS_PROBABILITY);
if(randomValue < WOUND_HEAD_PROBABILITY)
newWound->location = WOUND_HEAD;
else if(randomValue < WOUND_HEAD_PROBABILITY + WOUND_CHEST_PROBABILITY)
newWound->location = WOUND_CHEST;
else if(randomValue < WOUND_HEAD_PROBABILITY + WOUND_CHEST_PROBABILITY + WOUND_ARMS_PROBABILITY)
newWound->location = WOUND_ARMS;
else if(randomValue < WOUND_HEAD_PROBABILITY + WOUND_CHEST_PROBABILITY + WOUND_ARMS_PROBABILITY + WOUND_LEGS_PROBABILITY)
newWound->location = WOUND_LEGS;
else /**< This should *never* happen, put out an error or something */
newWound->location %= WOUND_LEGS; /**< WOUND_LEGS is probably the highest enum value, so % by it. */
/**< Next determine if it is a wound */
if(damage < WOUND_MINIMUM_DAMAGE) {
newWound->affectSkill = 0;
newWound->treated = 1;
} else {
newWound->affectSkill = 1;
newWound->treated = 0;
}
/**< Finally set the damage of the wound */
newWound->value = damage;
/**< The wound is created, just add it to the target now */
LIST_AddPointer(&target->chr.wounds, newWound);
/**< Subtract the damage from the current hit points. */
target->HP -= damage;
}
int CL_ActorAccuracyDecreaseByWounds (edict_t *target)
{
linkedList_t *woundList;
wound_t *wound;
int armWounds = 0, headWounds = 0, returnValue = 0;
/**< Calculate Arm Wounds */
woundList = target->chr.wounds;
while (woundList) {
wound = (wound_t *)woundList->data;
if ((wound->location == WOUND_ARMS) && wound->affectSkill) {
if (wound->treated)
armWounds += wound->value / 2;
else
armWounds += wound->value;
}
woundList = woundList->next;
}
/**< TODO: Value of all arm wounds is now stored in armWounds, do something with it here. */
/**< Calculate Head Wounds */
woundList = target->chr.wounds;
while (woundList) {
wound = (wound_t *)woundList->data;
if ((wound->location == WOUND_HEAD) && wound->affectSkill) {
if (wound->treated)
headWounds += wound->value / 2;
else
headWounds += wound->value;
}
woundList = woundList->next;
}
/**< TODO: Value of all head wounds is now stored in headWounds, do something with it here. */
return returnValue;
}
int CL_ActorShootTUIncreaseByWounds (edict_t *target)
{
linkedList_t *woundList;
wound_t *wound;
int armWounds = 0, returnValue = 0;
/**< Calculate Arm Wounds */
woundList = target->chr.wounds;
while (woundList) {
wound = (wound_t *)woundList->data;
if ((wound->location == WOUND_ARMS) && wound->affectSkill) {
if (wound->treated)
armWounds += wound->value / 2;
else
armWounds += wound->value;
}
woundList = woundList->next;
}
/**< TODO: Value of all arm wounds is now stored in armWounds, do something with it here. */
return returnValue;
}
/**
* @brief Treat the actor.
* @param[in] target Who is treated
* @param[in] damage /1000=type of healing, %1000 = amount of healing.
*/
void CL_ActorTreat (edict_t *target, const int damage)
{
int type, value, index, amount, woundNumber;
linkedList_t *woundList;
wound_t *treatWound;
type = damage / 1000;
value = damage % 1000;
/**< Sanity check on 'value' here if wanted. *
* I am leaving it out in case we want to subtract morale or something. */
if (type < 0)
type = -type;
if ( type == HEAL ) {
/**< First we locate the worst wound on the person being treated */
index = 0;
amount = 0;
woundNumber = 0;
woundList = target->chr.wounds;
while (woundList) {
treatWound = (wound_t *)woundList->data;
if ((!treatWound->treated) && (treatWound->value > amount)) {
amount = treatWound->value;
woundNumber = index;
}
index++;
woundList = woundList->next;
}
woundList = target->chr.wounds;
treatWound = (wound_t *)LIST_GetByIdx(woundList, woundNumber);
/**< Heal the wound a bit. We will simply subtract 10% of the wound from itself. */
treatWound->value -= treatWound->value / 10;
treatWound->treated = 1;
target->HP += treatWound->value / 10;
} else if (type == MORALE) {
target->morale -= value;
target->morale = min (target->morale, 100);
target->morale = max (target->morale, 0);
} else if (type == STUN) {
target->STUN -= value;
target->STUN = min (target->STUN, 255);
target->STUN = max (target->STUN, 0);
} else {
}
}