coverity scan CID 22457: logically dead code

the original TEACH_FRIENDS feature could not possibly have worked?
This commit is contained in:
Enno Rehling 2015-10-29 09:39:33 +01:00
parent f4c32acd05
commit e27c4b4164
1 changed files with 18 additions and 22 deletions

View File

@ -325,26 +325,29 @@ int teach_cmd(unit * u, struct order *ord)
#if TEACH_ALL #if TEACH_ALL
if (getparam(u->faction->locale) == P_ANY) { if (getparam(u->faction->locale) == P_ANY) {
unit *student = r->units; unit *student;
skill_t teachskill[MAXSKILLS]; skill_t teachskill[MAXSKILLS];
int i = 0; int t;
do {
sk = getskill(u->faction->locale); for (t = 0; sk != NOSKILL; ++t) {
teachskill[i++] = sk; teachskill[t] = getskill(u->faction->locale);
} while (sk != NOSKILL); };
while (teaching && student) {
if (student->faction == u->faction) { for (student = r->units; teaching && student; student = student->next) {
if (LongHunger(student)) if (LongHunger(student)) {
continue; continue;
} else if (student->faction == u->faction) {
if (getkeyword(student->thisorder) == K_STUDY) { if (getkeyword(student->thisorder) == K_STUDY) {
/* Input ist nun von student->thisorder !! */ /* Input ist nun von student->thisorder !! */
init_order(student->thisorder); init_order(student->thisorder);
sk = getskill(student->faction->locale); sk = getskill(student->faction->locale);
if (sk != NOSKILL && teachskill[0] != NOSKILL) { if (sk != NOSKILL && teachskill[0] != NOSKILL) {
for (i = 0; teachskill[i] != NOSKILL; ++i) for (t = 0; teachskill[t] != NOSKILL; ++t) {
if (sk == teachskill[i]) if (sk == teachskill[t]) {
break; break;
sk = teachskill[i]; }
}
sk = teachskill[t];
} }
if (sk != NOSKILL if (sk != NOSKILL
&& effskill_study(u, sk, 0) - TEACHDIFFERENCE > effskill_study(student, sk, 0)) { && effskill_study(u, sk, 0) - TEACHDIFFERENCE > effskill_study(student, sk, 0)) {
@ -352,14 +355,8 @@ int teach_cmd(unit * u, struct order *ord)
} }
} }
} }
student = student->next;
}
#ifdef TEACH_FRIENDS #ifdef TEACH_FRIENDS
while (teaching && student) { else if (alliedunit(u, student->faction, HELP_GUARD)) {
if (student->faction != u->faction
&& alliedunit(u, student->faction, HELP_GUARD)) {
if (LongHunger(student))
continue;
if (getkeyword(student->thisorder) == K_STUDY) { if (getkeyword(student->thisorder) == K_STUDY) {
/* Input ist nun von student->thisorder !! */ /* Input ist nun von student->thisorder !! */
init_order(student->thisorder); init_order(student->thisorder);
@ -370,9 +367,8 @@ int teach_cmd(unit * u, struct order *ord)
} }
} }
} }
student = student->next;
}
#endif #endif
}
} }
else else
#endif #endif