Hi James,
When I compiled ST EXP, I noticed the following warning :
Quote
e:\programs\simutrans_exp_src\source\simwerkz.cc(1150) : warning C4715: 'wkz_marker_t::work' : not all control paths return a value
Probably, the last return statement is misplaced -- it should be between the last and the 2nd last closing brackets, right?
Quote
const char *wkz_marker_t::work( karte_t *welt, spieler_t *sp, koord3d pos )
{
if(welt->ist_in_kartengrenzen(pos.get_2d())) {
grund_t *gr = welt->lookup(pos.get_2d())->get_kartenboden();
if (gr)
{
// check for underground mode
if (grund_t::underground_mode == grund_t::ugm_all ||
(grund_t::underground_mode == grund_t::ugm_level && gr->get_hoehe()>grund_t::underground_level)) {
return "";
}
if(gr && !gr->get_text())
{
const ding_t* thing = gr->obj_bei(0);
const label_t* l = gr->find<label_t>();
if(thing == NULL || thing->get_besitzer() == sp || (spieler_t::check_owner(thing->get_besitzer(), sp) && (thing->get_typ() != ding_t::gebaeude)))
{
if(!sp->can_afford(welt->get_einstellungen()->cst_buy_land))
{
return CREDIT_MESSAGE;
}
gr->obj_add(new label_t(welt, gr->get_pos(), sp, "\0"));
gr->find<label_t>()->zeige_info();
return "";
}
}
}
return "Das Feld gehoert\neinem anderen Spieler\n";
}
}
The text of the last returns says "Field is owned by another player". This wold be a missleading return for the outermost {}. It should sound like "Invalid coordidate beyond world bounds" or similar.
In which case, I suspect that the code is superfluous in any event - deleting fields is now allowed unless the number of fields is at or below the minimum, in which case a special error message appears notifying the player of the fact. So this error message seems to be a remnant of an earlier time (and therefore an issue from Simutrans-Standard rather than Simutrans-Experimental).
I didn't have time to study the code. What I want to point out is only that, all control paths should return something valid. :)