static PyObject* python_can_unit_paradrop(PyObject* self, PyObject* args) { int arg_punit; if(PyArg_ParseTuple(args, "i", &arg_punit) == 0) return NULL; bool retval = can_unit_paradrop((struct unit*)arg_punit); return Py_BuildValue("i", (int)retval); }
// TODO: Support irrigation modes JNIEXPORT jbyteArray JNICALL Java_net_hackcasual_freeciv_NativeHarness_getAvailableCommandsForActiveUnit (JNIEnv * env, jobject obj) { struct unit * pUnit; char availCommands[COM_UNIT_LAST]; int commandCount = 0; pUnit = head_of_units_in_focus(); if (pUnit) { struct tile *pTile = pUnit->tile; struct city *pCity = tile_city(pTile); struct terrain *pTerrain = tile_terrain(pTile); struct base_type *pbase; struct unit_list *punits = get_units_in_focus(); if (can_unit_build_city(pUnit)) { availCommands[commandCount++] = COM_BUILD_CITY; } if (can_unit_do_activity(pUnit, ACTIVITY_GOTO)) { availCommands[commandCount++] = COM_GO_TO; availCommands[commandCount++] = COM_GO_TO_CITY; } if (can_unit_do_activity(pUnit, ACTIVITY_SENTRY)) { availCommands[commandCount++] = COM_SENTRY; } if (can_unit_do_activity(pUnit, ACTIVITY_FORTIFYING)) { availCommands[commandCount++] = COM_FORTIFY; } if (can_unit_do_activity(pUnit, ACTIVITY_EXPLORE)) { availCommands[commandCount++] = COM_EXPLORE; } availCommands[commandCount++] = COM_DISBAND; if (can_unit_do_activity(pUnit, ACTIVITY_ROAD) || can_unit_do_activity(pUnit, ACTIVITY_RAILROAD)) { availCommands[commandCount++] = COM_ROAD; } if (can_unit_do_activity(pUnit, ACTIVITY_IRRIGATE)) { availCommands[commandCount++] = COM_IRRIGATION; } if (can_unit_do_autosettlers(pUnit)) { availCommands[commandCount++] = COM_AUTO_WORKER; } if (can_unit_do_connect(pUnit, ACTIVITY_IRRIGATE)) { availCommands[commandCount++] = COM_CONNECT_IRRIGATION; } if (can_unit_do_connect(pUnit, ACTIVITY_ROAD)) { availCommands[commandCount++] = COM_CONNECT_ROAD; } if (can_unit_do_connect(pUnit, ACTIVITY_RAILROAD)) { availCommands[commandCount++] = COM_CONNECT_RAILROAD; } availCommands[commandCount++] = COM_WAIT; if (unit_can_help_build_wonder_here(pUnit)) { availCommands[commandCount++] = COM_BUILD_WONDER; } if (unit_can_est_trade_route_here(pUnit)) { availCommands[commandCount++] = COM_TRADE_ROUTE; } if (can_unit_do_activity(pUnit, ACTIVITY_MINE)) { availCommands[commandCount++] = COM_MINE; } if (can_unit_do_activity(pUnit, ACTIVITY_TRANSFORM)) { availCommands[commandCount++] = COM_TRANSFORM; } pbase = get_base_by_gui_type(BASE_GUI_FORTRESS, pUnit, pUnit->tile); if (!pCity && pbase) { availCommands[commandCount++] = COM_FORTRESS; } pbase = get_base_by_gui_type(BASE_GUI_AIRBASE, pUnit, pUnit->tile); if (!pCity && pbase) { availCommands[commandCount++] = COM_AIRBASE; } if (can_unit_do_activity(pUnit, ACTIVITY_POLLUTION)) { availCommands[commandCount++] = COM_POLLUTION; } if (can_unit_do_activity(pUnit, ACTIVITY_FALLOUT)) { availCommands[commandCount++] = COM_FALLOUT; } if (can_unit_paradrop(pUnit)) { availCommands[commandCount++] = COM_PARADROP; } if (can_unit_do_activity(pUnit, ACTIVITY_PILLAGE)) { availCommands[commandCount++] = COM_FALLOUT; } if (pCity && can_unit_change_homecity(pUnit) && pCity->id != pUnit->homecity) { availCommands[commandCount++] = COM_HOMECITY; } if (pUnit->occupy && get_transporter_occupancy(pUnit) > 0) { availCommands[commandCount++] = COM_UNLOAD_TRANSPORT; } if (units_can_load(punits)) { availCommands[commandCount++] = COM_LOAD; } if (units_can_unload(punits)) { availCommands[commandCount++] = COM_UNLOAD; } if (pCity && pCity->airlift) { availCommands[commandCount++] = COM_AIRLIFT; } if (pCity && can_upgrade_unittype(client.conn.playing, unit_type(pUnit))) { availCommands[commandCount++] = COM_UPGRADE; } if (diplomat_can_do_action(pUnit, DIPLOMAT_ANY_ACTION, pUnit->tile)) { availCommands[commandCount++] = COM_DIPLOMAT; } if (unit_has_type_flag(pUnit, F_NUCLEAR)) { availCommands[commandCount++] = COM_NUKE; } } jbyteArray commands; commands = (*env)->NewByteArray(env, commandCount); (*env)->SetByteArrayRegion(env, commands, 0, commandCount, (jbyte *)availCommands); return commands; }