HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*
Bug #700906 » m-lua-unit-by-flag-1.patch
common/scriptcore/api_game_find.c | ||
---|---|---|
}
|
||
/*************************************************************************//**
|
||
Return a unit type for given role.
|
||
Return a unit type for given role or flag.
|
||
(Prior to 2.6.0, this worked only for roles.)
|
||
*****************************************************************************/
|
||
Unit_Type *api_find_role_unit_type(lua_State *L, const char *role_name,
|
||
Player *pplayer)
|
||
{
|
||
enum unit_role_id role;
|
||
int role_or_flag;
|
||
LUASCRIPT_CHECK_STATE(L, NULL);
|
||
LUASCRIPT_CHECK_ARG_NIL(L, role_name, 2, string, NULL);
|
||
role = unit_role_id_by_name(role_name, fc_strcasecmp);
|
||
role_or_flag = unit_role_id_by_name(role_name, fc_strcasecmp);
|
||
if (!unit_role_id_is_valid(role)) {
|
||
return NULL;
|
||
if (!unit_role_id_is_valid(role_or_flag)) {
|
||
role_or_flag = unit_type_flag_id_by_name(role_name, fc_strcasecmp);
|
||
if (!unit_type_flag_id_is_valid(role_or_flag)) {
|
||
return NULL;
|
||
}
|
||
}
|
||
if (pplayer) {
|
||
return best_role_unit_for_player(pplayer, role);
|
||
} else if (num_role_units(role) > 0) {
|
||
return get_role_unit(role, 0);
|
||
return best_role_unit_for_player(pplayer, role_or_flag);
|
||
} else if (num_role_units(role_or_flag) > 0) {
|
||
return get_role_unit(role_or_flag, 0);
|
||
} else {
|
||
return NULL;
|
||
}
|