Development > Newbie Coding

error: request for member 'data' in something not a structure or union

(1/1)

criusmac:
This compiles:


--- Code: --- woundList = target->chr.wounds;
index = LIST_Count(woundList);
for (i = 0; i < index; i++) {
wound = (wound_t *)LIST_GetByIdx(woundList, i);
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. */

--- End code ---

This is what it used to be:


--- Code: --- /**< 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. */

--- End code ---

If there a way to access the linked list contents faster than using the functions?

bayo:
woundList is a pointer no? then use "woundList->" instead of "woundList."

criusmac:
Yup, that was it. I misread the error message. My bad.

Navigation

[0] Message Index

Go to full version