Compare commits

...

20 Commits

Author SHA1 Message Date
Joseph Rafael Ferrer cb02195d9f Fix infinite loop on parsing spells on arm64. (#42951) 2020-12-09 12:13:49 +03:00
Zhilkin Serg fe67854608 Prevent app restart when USB keyboard is plugged 2020-12-09 12:10:43 +03:00
anothersimulacrum b33bf66cc4 Use reference in loop, not copy 2020-12-09 11:15:28 +03:00
Serhiy Zahoriya 61c109645a Backported #41346: fix root cellars on map load
Co-authored-by: Hirmuolio <hirmuolio@gmail.com>
2020-06-18 12:03:44 -07:00
Serhiy Zahoriya 3dd040eed2 Backported #40025: Fix a crash when npc tries to heal horse-mounted player
Co-authored-by: Qrox <qrox@sina.com>
2020-06-18 12:03:44 -07:00
Serhiy Zahoriya ef29ca7c4b Backported #39405: Update string extraction script and fix computer translation
Co-authored-by: Qrox <qrox@sina.com>
2020-06-18 12:03:44 -07:00
Serhiy Zahoriya 2a6ac5bcc0 Backported fixes for ice lab spoiling #39813
Co-authored-by: Hirmuolio <hirmuolio@gmail.com>
2020-06-18 12:03:44 -07:00
Serhiy Zahoriya 767d9c26e9 Skip unnecessary weather calculations for root cellar #41324 2020-06-18 12:03:44 -07:00
ZhilkinSerg e184c6a74e Disallow SDL orientation changes 2020-05-20 15:16:59 +03:00
ZhilkinSerg 1a0a534d80 Update Android precompiled dependencies (2020-04-18) 2020-05-20 15:16:05 +03:00
Qrox a07ce29fc6 Fix crash when NPC gives player equipment 2020-04-12 00:08:11 -05:00
tenmillimaster 0f1f2f2921 bp migrations & recipes 2020-04-12 00:08:11 -05:00
Tiefoone 707191c2e4 Floating point error correction. (#39230) 2020-04-12 00:08:11 -05:00
Tiefoone fc47a700b0 Prevent nearby NPC-owned items showing up in trades unless they are a shopkeeper. 2020-04-12 00:08:11 -05:00
Kevin Granade 8eafa19a41 Bypass downing immunity when knocked down due to instability. 2020-04-12 00:08:11 -05:00
ZhilkinSerg 5df5337af3 Add savegame migration for rural house 2020-04-12 00:08:11 -05:00
Tiefoone 49016c0de7 Include aluminum in TV materials to prevent cutting into plastic chunks. 2020-04-12 00:08:11 -05:00
ZhilkinSerg 3244627ef2 Misc small fixes for Android builds (2020-04-02) (#39168)
* Only build experimental flavor on Travis

* Guard unused function in Android builds

* Ignore pragmas unknown to Android compiler
2020-04-12 00:08:11 -05:00
KurzedMetal 54fe9cab04 Fix wield action costing double than it should 2020-04-12 00:08:11 -05:00
saurocyte 958d22b091 Fix negative explosion damage 2020-04-12 00:08:11 -05:00
32 changed files with 363 additions and 208 deletions
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -43,7 +43,7 @@
android:launchMode="singleInstance"
android:keepScreenOn="true"
android:screenOrientation="userLandscape"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -55,7 +55,7 @@
android:launchMode="singleInstance"
android:keepScreenOn="true"
android:screenOrientation="userLandscape"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
>
</activity>
</application>
@@ -1,5 +1,7 @@
package org.libsdl.app;
import android.hardware.usb.UsbDevice;
interface HIDDevice
{
public int getId();
@@ -9,6 +11,7 @@ interface HIDDevice
public int getVersion();
public String getManufacturerName();
public String getProductName();
public UsbDevice getDevice();
public boolean open();
public int sendFeatureReport(byte[] report);
public int sendOutputReport(byte[] report);
@@ -9,6 +9,7 @@ import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothGattService;
import android.hardware.usb.UsbDevice;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
@@ -165,13 +166,13 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
mHandler = new Handler(Looper.getMainLooper());
mGatt = connectGatt();
final HIDDeviceBLESteamController finalThis = this;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
finalThis.checkConnectionForChromebookIssue();
}
}, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
// final HIDDeviceBLESteamController finalThis = this;
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// finalThis.checkConnectionForChromebookIssue();
// }
// }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
}
public String getIdentifier() {
@@ -469,7 +470,7 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
// Only register controller with the native side once it has been fully configured
if (!isRegistered()) {
Log.v(TAG, "Registering Steam Controller with ID: " + getId());
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0);
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0);
setRegistered();
}
}
@@ -563,6 +564,11 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
return "Steam Controller";
}
@Override
public UsbDevice getDevice() {
return null;
}
@Override
public boolean open() {
return true;
@@ -19,8 +19,9 @@ import android.hardware.usb.*;
import android.os.Handler;
import android.os.Looper;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class HIDDeviceManager {
@@ -50,7 +51,6 @@ public class HIDDeviceManager {
private Context mContext;
private HashMap<Integer, HIDDevice> mDevicesById = new HashMap<Integer, HIDDevice>();
private HashMap<UsbDevice, HIDDeviceUSB> mUSBDevices = new HashMap<UsbDevice, HIDDeviceUSB>();
private HashMap<BluetoothDevice, HIDDeviceBLESteamController> mBluetoothDevices = new HashMap<BluetoothDevice, HIDDeviceBLESteamController>();
private int mNextDeviceId = 0;
private SharedPreferences mSharedPreferences = null;
@@ -241,31 +241,20 @@ public class HIDDeviceManager {
}
}
private boolean isHIDDeviceUSB(UsbDevice usbDevice) {
for (int interface_number = 0; interface_number < usbDevice.getInterfaceCount(); ++interface_number) {
if (isHIDDeviceInterface(usbDevice, interface_number)) {
return true;
}
}
return false;
}
private boolean isHIDDeviceInterface(UsbDevice usbDevice, int interface_number) {
UsbInterface usbInterface = usbDevice.getInterface(interface_number);
private boolean isHIDDeviceInterface(UsbDevice usbDevice, UsbInterface usbInterface) {
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_HID) {
return true;
}
if (interface_number == 0) {
if (isXbox360Controller(usbDevice, usbInterface) || isXboxOneController(usbDevice, usbInterface)) {
return true;
}
if (isXbox360Controller(usbDevice, usbInterface) || isXboxOneController(usbDevice, usbInterface)) {
return true;
}
return false;
}
private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) {
final int XB360_IFACE_SUBCLASS = 93;
final int XB360_IFACE_PROTOCOL = 1; // Wired only
final int XB360_IFACE_PROTOCOL = 1; // Wired
final int XB360W_IFACE_PROTOCOL = 129; // Wireless
final int[] SUPPORTED_VENDORS = {
0x0079, // GPD Win 2
0x044f, // Thrustmaster
@@ -275,8 +264,9 @@ public class HIDDeviceManager {
0x06a3, // Saitek
0x0738, // Mad Catz
0x07ff, // Mad Catz
0x0e6f, // Unknown
0x0e6f, // PDP
0x0f0d, // Hori
0x1038, // SteelSeries
0x11c9, // Nacon
0x12ab, // Unknown
0x1430, // RedOctane
@@ -291,7 +281,8 @@ public class HIDDeviceManager {
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
usbInterface.getInterfaceSubclass() == XB360_IFACE_SUBCLASS &&
usbInterface.getInterfaceProtocol() == XB360_IFACE_PROTOCOL) {
(usbInterface.getInterfaceProtocol() == XB360_IFACE_PROTOCOL ||
usbInterface.getInterfaceProtocol() == XB360W_IFACE_PROTOCOL)) {
int vendor_id = usbDevice.getVendorId();
for (int supportedVid : SUPPORTED_VENDORS) {
if (vendor_id == supportedVid) {
@@ -308,13 +299,15 @@ public class HIDDeviceManager {
final int[] SUPPORTED_VENDORS = {
0x045e, // Microsoft
0x0738, // Mad Catz
0x0e6f, // Unknown
0x0e6f, // PDP
0x0f0d, // Hori
0x1532, // Razer Wildcat
0x24c6, // PowerA
0x2e24, // Hyperkin
};
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
if (usbInterface.getId() == 0 &&
usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
usbInterface.getInterfaceSubclass() == XB1_IFACE_SUBCLASS &&
usbInterface.getInterfaceProtocol() == XB1_IFACE_PROTOCOL) {
int vendor_id = usbDevice.getVendorId();
@@ -328,45 +321,45 @@ public class HIDDeviceManager {
}
private void handleUsbDeviceAttached(UsbDevice usbDevice) {
if (isHIDDeviceUSB(usbDevice)) {
connectHIDDeviceUSB(usbDevice);
}
connectHIDDeviceUSB(usbDevice);
}
private void handleUsbDeviceDetached(UsbDevice usbDevice) {
HIDDeviceUSB device = mUSBDevices.get(usbDevice);
if (device == null)
return;
int id = device.getId();
mUSBDevices.remove(usbDevice);
mDevicesById.remove(id);
device.shutdown();
HIDDeviceDisconnected(id);
List<Integer> devices = new ArrayList<Integer>();
for (HIDDevice device : mDevicesById.values()) {
if (usbDevice.equals(device.getDevice())) {
devices.add(device.getId());
}
}
for (int id : devices) {
HIDDevice device = mDevicesById.get(id);
mDevicesById.remove(id);
device.shutdown();
HIDDeviceDisconnected(id);
}
}
private void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) {
HIDDeviceUSB device = mUSBDevices.get(usbDevice);
if (device == null)
return;
boolean opened = false;
if (permission_granted) {
opened = device.open();
for (HIDDevice device : mDevicesById.values()) {
if (usbDevice.equals(device.getDevice())) {
boolean opened = false;
if (permission_granted) {
opened = device.open();
}
HIDDeviceOpenResult(device.getId(), opened);
}
}
HIDDeviceOpenResult(device.getId(), opened);
}
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
synchronized (this) {
for (int interface_number = 0; interface_number < usbDevice.getInterfaceCount(); interface_number++) {
if (isHIDDeviceInterface(usbDevice, interface_number)) {
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_number);
for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) {
UsbInterface usbInterface = usbDevice.getInterface(interface_index);
if (isHIDDeviceInterface(usbDevice, usbInterface)) {
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
int id = device.getId();
mUSBDevices.put(usbDevice, device);
mDevicesById.put(id, device);
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), interface_number);
break;
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), usbInterface.getId(), usbInterface.getInterfaceClass(), usbInterface.getInterfaceSubclass(), usbInterface.getInterfaceProtocol());
}
}
}
@@ -563,33 +556,27 @@ public class HIDDeviceManager {
//////////////////////////////////////////////////////////////////////////////////////////////////////
public boolean openDevice(int deviceID) {
Log.v(TAG, "openDevice deviceID=" + deviceID);
HIDDevice device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return false;
}
// Look to see if this is a USB device and we have permission to access it
for (HIDDeviceUSB device : mUSBDevices.values()) {
if (deviceID == device.getId()) {
UsbDevice usbDevice = device.getDevice();
if (!mUsbManager.hasPermission(usbDevice)) {
HIDDeviceOpenPending(deviceID);
try {
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), 0));
} catch (Exception e) {
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
HIDDeviceOpenResult(deviceID, false);
}
return false;
}
break;
UsbDevice usbDevice = device.getDevice();
if (usbDevice != null && !mUsbManager.hasPermission(usbDevice)) {
HIDDeviceOpenPending(deviceID);
try {
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), 0));
} catch (Exception e) {
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
HIDDeviceOpenResult(deviceID, false);
}
return false;
}
try {
Log.v(TAG, "openDevice deviceID=" + deviceID);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return false;
}
return device.open();
} catch (Exception e) {
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
@@ -599,7 +586,7 @@ public class HIDDeviceManager {
public int sendOutputReport(int deviceID, byte[] report) {
try {
Log.v(TAG, "sendOutputReport deviceID=" + deviceID + " length=" + report.length);
//Log.v(TAG, "sendOutputReport deviceID=" + deviceID + " length=" + report.length);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
@@ -616,7 +603,7 @@ public class HIDDeviceManager {
public int sendFeatureReport(int deviceID, byte[] report) {
try {
Log.v(TAG, "sendFeatureReport deviceID=" + deviceID + " length=" + report.length);
//Log.v(TAG, "sendFeatureReport deviceID=" + deviceID + " length=" + report.length);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
@@ -633,7 +620,7 @@ public class HIDDeviceManager {
public boolean getFeatureReport(int deviceID, byte[] report) {
try {
Log.v(TAG, "getFeatureReport deviceID=" + deviceID);
//Log.v(TAG, "getFeatureReport deviceID=" + deviceID);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
@@ -672,7 +659,7 @@ public class HIDDeviceManager {
private native void HIDDeviceRegisterCallback();
private native void HIDDeviceReleaseCallback();
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number);
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number, int interface_class, int interface_subclass, int interface_protocol);
native void HIDDeviceOpenPending(int deviceID);
native void HIDDeviceOpenResult(int deviceID, boolean opened);
native void HIDDeviceDisconnected(int deviceID);
@@ -11,6 +11,7 @@ class HIDDeviceUSB implements HIDDevice {
protected HIDDeviceManager mManager;
protected UsbDevice mDevice;
protected int mInterfaceIndex;
protected int mInterface;
protected int mDeviceId;
protected UsbDeviceConnection mConnection;
@@ -20,16 +21,17 @@ class HIDDeviceUSB implements HIDDevice {
protected boolean mRunning;
protected boolean mFrozen;
public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_number) {
public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_index) {
mManager = manager;
mDevice = usbDevice;
mInterface = interface_number;
mInterfaceIndex = interface_index;
mInterface = mDevice.getInterface(mInterfaceIndex).getId();
mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier());
mRunning = false;
}
public String getIdentifier() {
return String.format("%s/%x/%x", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId());
return String.format("%s/%x/%x/%d", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId(), mInterfaceIndex);
}
@Override
@@ -88,6 +90,7 @@ class HIDDeviceUSB implements HIDDevice {
return result;
}
@Override
public UsbDevice getDevice() {
return mDevice;
}
@@ -104,19 +107,15 @@ class HIDDeviceUSB implements HIDDevice {
return false;
}
// Force claim all interfaces
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
UsbInterface iface = mDevice.getInterface(i);
if (!mConnection.claimInterface(iface, true)) {
Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
close();
return false;
}
// Force claim our interface
UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
if (!mConnection.claimInterface(iface, true)) {
Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
close();
return false;
}
// Find the endpoints
UsbInterface iface = mDevice.getInterface(mInterface);
for (int j = 0; j < iface.getEndpointCount(); j++) {
UsbEndpoint endpt = iface.getEndpoint(j);
switch (endpt.getDirection()) {
@@ -166,7 +165,7 @@ class HIDDeviceUSB implements HIDDevice {
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT,
0x09/*HID set_report*/,
(3/*HID feature*/ << 8) | report_number,
0,
mInterface,
report, offset, length,
1000/*timeout millis*/);
@@ -210,7 +209,7 @@ class HIDDeviceUSB implements HIDDevice {
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN,
0x01/*HID get_report*/,
(3/*HID feature*/ << 8) | report_number,
0,
mInterface,
report, offset, length,
1000/*timeout millis*/);
@@ -250,10 +249,8 @@ class HIDDeviceUSB implements HIDDevice {
mInputThread = null;
}
if (mConnection != null) {
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
UsbInterface iface = mDevice.getInterface(i);
mConnection.releaseInterface(iface);
}
UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
mConnection.releaseInterface(iface);
mConnection.close();
mConnection = null;
}
@@ -39,8 +39,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
private static final String TAG = "SDL";
public static boolean mIsResumedCalled, mHasFocus;
public static boolean mAllowSDLOrientationChanges = false;
public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24);
public static boolean mAllowSDLOrientationChanges = false;
// Cursor types
private static final int SDL_SYSTEM_CURSOR_NONE = -1;
@@ -300,10 +300,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return;
}
if (mHIDDeviceManager != null) {
mHIDDeviceManager.setFrozen(true);
}
SDLActivity.handleNativeState();
}
@@ -315,10 +311,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return;
}
if (mHIDDeviceManager != null) {
mHIDDeviceManager.setFrozen(false);
}
SDLActivity.handleNativeState();
}
@@ -327,9 +319,12 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
protected void onPause() {
Log.v(TAG, "onPause()");
super.onPause();
if (mHIDDeviceManager != null) {
mHIDDeviceManager.setFrozen(true);
}
if (!mHasMultiWindow) {
pauseNativeThread();
mSurface.setVisibility(View.GONE);
}
}
@@ -337,8 +332,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
protected void onResume() {
Log.v(TAG, "onResume()");
super.onResume();
if (mHIDDeviceManager != null) {
mHIDDeviceManager.setFrozen(false);
}
if (!mHasMultiWindow) {
mSurface.setVisibility(View.VISIBLE);
resumeNativeThread();
}
}
@@ -472,7 +470,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
// Default system back button behavior.
//super.onBackPressed();
if (!isFinishing()) {
super.onBackPressed();
}
}
// Called by JNI from SDL.
@@ -485,7 +485,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
runOnUiThread(new Runnable() {
@Override
public void run() {
SDLActivity.this.superOnBackPressed();
if (!SDLActivity.this.isFinishing()) {
SDLActivity.this.superOnBackPressed();
}
}
});
}
@@ -654,6 +656,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
mScreenKeyboardShown = false;
mSurface.requestFocus();
}
break;
case COMMAND_SET_KEEP_SCREEN_ON:
@@ -745,7 +749,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
}
if (bShouldWait) {
if (bShouldWait && (SDLActivity.getContext() != null)) {
// We'll wait for the surfaceChanged() method, which will notify us
// when called. That way, we know our current size is really the
// size we need, instead of grabbing a size that's still got
@@ -799,6 +803,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
public static native void nativeSetenv(String name, String value);
public static native void onNativeOrientationChanged(int orientation);
public static native void nativeAddTouch(int touchId, String name);
public static native void nativePermissionResult(int requestCode, boolean result);
/**
* This method is called by SDL using JNI.
@@ -833,38 +838,63 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
*/
public void setOrientationBis(int w, int h, boolean resizable, String hint)
{
int orientation = -1;
int orientation_landscape = -1;
int orientation_portrait = -1;
/* If set, hint "explicitly controls which UI orientations are allowed". */
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
} else if (hint.contains("LandscapeRight")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else if (hint.contains("LandscapeLeft")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
} else if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
} else if (hint.contains("Portrait")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
} else if (hint.contains("PortraitUpsideDown")) {
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
}
/* no valid hint */
if (orientation == -1) {
if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
} else if (hint.contains("Portrait")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
} else if (hint.contains("PortraitUpsideDown")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
}
boolean is_landscape_allowed = (orientation_landscape == -1 ? false : true);
boolean is_portrait_allowed = (orientation_portrait == -1 ? false : true);
int req = -1; /* Requested orientation */
/* No valid hint, nothing is explicitly allowed */
if (!is_portrait_allowed && !is_landscape_allowed) {
if (resizable) {
/* no fixed orientation */
/* All orientations are allowed */
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
} else {
if (w > h) {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
/* Fixed window and nothing specified. Get orientation from w/h of created window */
req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
}
} else {
/* At least one orientation is allowed */
if (resizable) {
if (is_portrait_allowed && is_landscape_allowed) {
/* hint allows both landscape and portrait, promote to full sensor */
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
} else {
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
/* Use the only one allowed "orientation" */
req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);
}
} else {
/* Fixed window and both orientations are allowed. Choose one. */
if (is_portrait_allowed && is_landscape_allowed) {
req = (w > h ? orientation_landscape : orientation_portrait);
} else {
/* Use the only one allowed "orientation" */
req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);
}
}
}
Log.v("SDL", "setOrientation() orientation=" + orientation + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
if (mAllowSDLOrientationChanges && orientation != -1) {
mSingleton.setRequestedOrientation(orientation);
Log.v("SDL", "setOrientation() requestedOrientation=" + req + " width=" + w +" height="+ h +" resizable=" + resizable + " hint=" + hint);
if (mAllowSDLOrientationChanges && req != -1) {
mSingleton.setRequestedOrientation(req);
}
}
@@ -992,6 +1022,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
if (Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.equals("X96-W")) {
return true;
}
if (Build.MANUFACTURER.equals("Amlogic") && Build.MODEL.startsWith("TV")) {
return true;
}
return false;
}
@@ -1001,6 +1034,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
public static boolean isTablet() {
DisplayMetrics metrics = new DisplayMetrics();
Activity activity = (Activity)getContext();
if (activity == null) {
return false;
}
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
double dWidthInches = metrics.widthPixels / (double)metrics.xdpi;
@@ -1016,6 +1052,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
* This method is called by SDL using JNI.
*/
public static boolean isChromebook() {
if (getContext() == null) {
return false;
}
return getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
}
@@ -1587,6 +1626,32 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
return true;
}
/**
* This method is called by SDL using JNI.
*/
public static void requestPermission(String permission, int requestCode) {
if (Build.VERSION.SDK_INT < 23) {
nativePermissionResult(requestCode, true);
return;
}
Activity activity = (Activity)getContext();
if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
activity.requestPermissions(new String[]{permission}, requestCode);
} else {
nativePermissionResult(requestCode, true);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
nativePermissionResult(requestCode, true);
} else {
nativePermissionResult(requestCode, false);
}
}
}
/**
@@ -1612,7 +1677,7 @@ class SDLMain implements Runnable {
Log.v("SDL", "Finished main function");
if (SDLActivity.mSingleton.isFinishing()) {
if (SDLActivity.mSingleton == null || SDLActivity.mSingleton.isFinishing()) {
// Activity is already being destroyed
} else {
// Let's finish the Activity
@@ -2124,24 +2189,17 @@ class DummyEdit extends View implements View.OnKeyListener {
//
@Override
public boolean onKeyPreIme (int keyCode, KeyEvent event) {
// HACK: Make sure the SDL activity receives native events for back button, even if DummyEdit is in focus
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (event.getAction()==KeyEvent.ACTION_DOWN)
SDLActivity.onNativeKeyDown(keyCode);
else if (event.getAction()==KeyEvent.ACTION_UP)
SDLActivity.onNativeKeyUp(keyCode);
}
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
// FIXME: A more effective solution would be to assume our Layout to be RelativeLayout or LinearLayout
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
//if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
// if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
// SDLActivity.onNativeKeyboardFocusLost();
// }
//}
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
SDLActivity.onNativeKeyboardFocusLost();
}
}
return super.onKeyPreIme(keyCode, event);
}
@@ -2149,7 +2207,7 @@ class DummyEdit extends View implements View.OnKeyListener {
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
ic = new SDLInputConnection(this, true);
outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL;
outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
| EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;
+1 -1
View File
@@ -146,7 +146,7 @@ then
cd android
# Specify dumb terminal to suppress gradle's constatnt output of time spent building, which
# fills the log with nonsense.
TERM=dumb ./gradlew assembleRelease -Pj=$num_jobs -Plocalize=false -Pabi_arm_32=false -Pabi_arm_64=true -Pdeps=/home/travis/build/CleverRaven/Cataclysm-DDA/android/app/deps.zip
TERM=dumb ./gradlew assembleExperimentalRelease -Pj=$num_jobs -Plocalize=false -Pabi_arm_32=false -Pabi_arm_64=true -Pdeps=/home/travis/build/CleverRaven/Cataclysm-DDA/android/app/deps.zip
else
make -j "$num_jobs" RELEASE=1 CCACHE=1 BACKTRACE=1 CROSS="$CROSS_COMPILATION" LINTJSON=0
+1 -1
View File
@@ -787,7 +787,7 @@
"name": { "str": "television" },
"description": "A large LCD television, full of delicious electronics.",
"price": 0,
"material": "plastic",
"material": [ "aluminum", "plastic" ],
"weight": "15000 g",
"volume": "20 L",
"bashing": 5,
+6 -1
View File
@@ -301,7 +301,12 @@
"house_north",
"house_south",
"house_east",
"house_west"
"house_west",
"rural_house",
"rural_house_north",
"rural_house_south",
"rural_house_east",
"rural_house_west"
]
}
]
@@ -264,9 +264,14 @@
"replace": "reloaded_rifle_huge_AP"
},
{
"id": [ "36navy", "44army" ],
"id": [ "36navy", "44army", "flintlock_ammo" ],
"type": "MIGRATION",
"replace": "flintlock_ammo"
"replace": "black_powder_ball"
},
{
"id": [ "flintlock_shot" ],
"type": "MIGRATION",
"replace": "black_powder_shot"
},
{
"id": [ "40x46mm_m1006" ],
@@ -1624,6 +1624,26 @@
"result": "reloaded_762_m87",
"obsolete": true
},
{
"type": "recipe",
"result": "36navy",
"obsolete": true
},
{
"type": "recipe",
"result": "44army",
"obsolete": true
},
{
"type": "recipe",
"result": "flintlock_ammo",
"obsolete": true
},
{
"type": "recipe",
"result": "flintlock_shot",
"obsolete": true
},
{
"type": "recipe",
"result": "bot_crows_m240",
@@ -1,4 +1,38 @@
[
{
"result": "black_powder_ball",
"type": "recipe",
"category": "CC_AMMO",
"subcategory": "CSC_AMMO_RIFLE",
"skill_used": "fabrication",
"difficulty": 3,
"skills_required": [ "gun", 1 ],
"time": "1 m",
"batch_time_factors": [ 60, 5 ],
"autolearn": true,
"charges": 1,
"reversible": true,
"using": [ [ "ammo_bullet", 10 ] ],
"qualities": [ { "id": "CUT", "level": 1 } ],
"components": [ [ [ "chem_black_powder", 5 ] ], [ [ "paper", 1 ] ] ]
},
{
"result": "black_powder_shot",
"type": "recipe",
"category": "CC_AMMO",
"subcategory": "CSC_AMMO_RIFLE",
"skill_used": "fabrication",
"difficulty": 3,
"skills_required": [ "gun", 1 ],
"time": "1 m",
"batch_time_factors": [ 60, 5 ],
"autolearn": true,
"charges": 1,
"reversible": true,
"using": [ [ "ammo_bullet", 10 ] ],
"qualities": [ { "id": "CUT", "level": 1 } ],
"components": [ [ [ "chem_black_powder", 5 ] ], [ [ "paper", 1 ] ] ]
},
{
"result": "reloaded_rifle_ball",
"type": "recipe",
+14 -4
View File
@@ -64,8 +64,10 @@ ignore_files = {os.path.normpath(i) for i in {
ignorable = {
"ammo_effect",
"behavior",
"charge_removal_blacklist",
"city_building",
"colordef",
"disease_type",
"emit",
"enchantment",
"event_transformation",
@@ -93,6 +95,7 @@ ignorable = {
"region_settings",
"requirement",
"rotatable_symbol",
"SCENARIO_BLACKLIST",
"scent_type",
"skill_boost",
"TRAIT_BLACKLIST",
@@ -247,6 +250,9 @@ def extract_martial_art(item):
if "description" in item:
writestr(outfile, item["description"],
comment="Description for martial art '{}'".format(name))
if "initiate" in item:
writestr(outfile, item["initiate"], format_strings=True,
comment="initiate message for martial art '{}'".format(name))
onhit_buffs = item.get("onhit_buffs", list())
static_buffs = item.get("static_buffs", list())
onmove_buffs = item.get("onmove_buffs", list())
@@ -641,10 +647,14 @@ def extract_missiondef(item):
def extract_mutation(item):
outfile = get_outfile("mutation")
item_name = found = item.get("name")
item_name_or_id = found = item.get("name")
if found is None:
raise WrongJSONItem("JSON item don't contain 'name' field", item)
writestr(outfile, found)
if "copy-from" in item:
item_name_or_id = item["id"]
else:
raise WrongJSONItem("JSON item don't contain 'name' field", item)
else:
writestr(outfile, found)
simple_fields = [ "description" ]
@@ -652,7 +662,7 @@ def extract_mutation(item):
found = item.get(f)
# Need that check due format string argument
if found is not None:
writestr(outfile, found, comment="Description for {}".format(item_name))
writestr(outfile, found, comment="Description for {}".format(item_name_or_id))
if "attacks" in item:
attacks = item.get("attacks")
+1 -1
View File
@@ -852,7 +852,7 @@ bool advanced_inventory::move_all_items( bool nested_call )
// Check some preconditions to quickly leave the function.
size_t liquid_items = 0;
for( const advanced_inv_listitem elem : spane.items ) {
for( const advanced_inv_listitem &elem : spane.items ) {
for( const item *elemit : elem.items ) {
if( elemit->made_of_from_type( LIQUID ) && !elemit->is_frozen_liquid() ) {
liquid_items++;
+3 -2
View File
@@ -377,10 +377,11 @@ struct enum_traits<computer_failure_type> {
computer_option computer_option::from_json( const JsonObject &jo )
{
const std::string name = jo.get_string( "name" );
translation name;
jo.read( "name", name );
const computer_action action = jo.get_enum_value<computer_action>( "action" );
const int sec = jo.get_int( "security", 0 );
return computer_option( name, action, sec );
return computer_option( name.translated(), action, sec );
}
computer_failure computer_failure::from_json( const JsonObject &jo )
+1 -1
View File
@@ -266,7 +266,7 @@ bool Creature::sees( const tripoint &t, bool is_avatar, int range_mod ) const
g->m.ambient_light_at( t ) > g->natural_light_level( t.z ) ) ) {
int range = 0;
if( g->m.ambient_light_at( t ) > g->natural_light_level( t.z ) ) {
range = wanted_range;
range = MAX_VIEW_DISTANCE;
} else {
range = range_min;
}
+1 -1
View File
@@ -970,7 +970,7 @@ std::string game_info::operating_system()
#endif
}
#if !defined(__CYGWIN__) && ( defined (__linux__) || defined(unix) || defined(__unix__) || defined(__unix) || ( defined(__APPLE__) && defined(__MACH__) ) || defined(BSD) ) // linux; unix; MacOs; BSD
#if !defined(__CYGWIN__) && !defined (__ANDROID__) && ( defined (__linux__) || defined(unix) || defined(__unix__) || defined(__unix) || ( defined(__APPLE__) && defined(__MACH__) ) || defined(BSD) ) // linux; unix; MacOs; BSD
/** Execute a command with the shell by using `popen()`.
* @param command The full command to execute.
* @note The output buffer is limited to 512 characters.
+1 -1
View File
@@ -309,7 +309,7 @@ static void do_blast( const tripoint &p, const float power,
player *pl = dynamic_cast<player *>( critter );
if( pl == nullptr ) {
// TODO: player's fault?
const double dmg = force - critter->get_armor_bash( bp_torso ) / 2.0;
const double dmg = std::max( force - critter->get_armor_bash( bp_torso ) / 2.0, 0.0 );
const int actual_dmg = rng_float( dmg * 2, dmg * 3 );
critter->apply_damage( nullptr, bp_torso, actual_dmg );
critter->check_dead_state();
+12 -9
View File
@@ -4538,16 +4538,22 @@ template const Creature *game::critter_at<Creature>( const tripoint &, bool ) co
template<typename T>
shared_ptr_fast<T> game::shared_from( const T &critter )
{
if( const shared_ptr_fast<monster> mon_ptr = critter_tracker->find( critter.pos() ) ) {
return std::dynamic_pointer_cast<T>( mon_ptr );
}
if( static_cast<const Creature *>( &critter ) == static_cast<const Creature *>( &u ) ) {
// u is not stored in a shared_ptr, but it won't go out of scope anyway
return std::dynamic_pointer_cast<T>( u_shared_ptr );
}
for( auto &cur_npc : active_npc ) {
if( static_cast<const Creature *>( cur_npc.get() ) == static_cast<const Creature *>( &critter ) ) {
return std::dynamic_pointer_cast<T>( cur_npc );
if( critter.is_monster() ) {
if( const shared_ptr_fast<monster> mon_ptr = critter_tracker->find( critter.pos() ) ) {
if( static_cast<const Creature *>( mon_ptr.get() ) == static_cast<const Creature *>( &critter ) ) {
return std::dynamic_pointer_cast<T>( mon_ptr );
}
}
}
if( critter.is_npc() ) {
for( auto &cur_npc : active_npc ) {
if( static_cast<const Creature *>( cur_npc.get() ) == static_cast<const Creature *>( &critter ) ) {
return std::dynamic_pointer_cast<T>( cur_npc );
}
}
}
return nullptr;
@@ -8482,7 +8488,6 @@ void game::wield( item_location &loc )
worn_index = Character::worn_position_to_index( item_pos );
}
}
int move_cost = loc.obtain_cost( u );
loc.remove_item();
if( !u.wield( to_wield ) ) {
switch( location_type ) {
@@ -8512,8 +8517,6 @@ void game::wield( item_location &loc )
}
return;
}
u.mod_moves( -move_cost );
}
void game::wield()
+2 -3
View File
@@ -8486,8 +8486,7 @@ void item::process_temperature_rot( float insulation, const tripoint &pos,
const weather_generator &wgen = g->weather.get_cur_weather_gen();
const unsigned int seed = g->get_seed();
const tripoint &local = g->m.getlocal( pos );
int local_mod = g->new_game ? 0 : g->m.get_temperature( local );
int local_mod = g->new_game ? 0 : g->m.get_temperature( pos );
int enviroment_mod;
// Toilets and vending machines will try to get the heat radiation and convection during mapgen and segfault.
@@ -8510,7 +8509,7 @@ void item::process_temperature_rot( float insulation, const tripoint &pos,
//Use weather if above ground, use map temp if below
double env_temperature = 0;
if( pos.z >= 0 ) {
if( pos.z >= 0 && flag != TEMP_ROOT_CELLAR ) {
double weather_temperature = wgen.get_weather_temperature( pos, time, seed );
env_temperature = weather_temperature + enviroment_mod + local_mod;
} else {
+1
View File
@@ -1242,6 +1242,7 @@ float fastexp( float x )
int i;
} u, v;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
u.i = static_cast<long long>( 6051102 * x + 1056478197 );
+3 -3
View File
@@ -976,9 +976,9 @@ std::string spell::damage_type_string() const
// constants defined below are just for the formula to be used,
// in order for the inverse formula to be equivalent
constexpr float a = 6200.0;
constexpr float b = 0.146661;
constexpr float c = -62.5;
constexpr double a = 6200.0;
constexpr double b = 0.146661;
constexpr double c = -62.5;
int spell::get_level() const
{
+12 -7
View File
@@ -6687,13 +6687,13 @@ void map::loadn( const tripoint &grid, const bool update_vehicles )
abs_sub.z = old_abs_z;
}
bool map::has_rotten_away( item &itm, const tripoint &pnt ) const
bool map::has_rotten_away( item &itm, const tripoint &pnt, const temperature_flag flag ) const
{
if( itm.is_corpse() && itm.goes_bad() ) {
itm.process_temperature_rot( 1, pnt, nullptr );
itm.process_temperature_rot( 1, pnt, nullptr, flag );
return itm.get_rot() > 10_days && !itm.can_revive();
} else if( itm.goes_bad() ) {
itm.process_temperature_rot( 1, pnt, nullptr );
itm.process_temperature_rot( 1, pnt, nullptr, flag );
return itm.has_rotten_away();
} else if( itm.type->container && itm.type->container->preserves ) {
// Containers like tin cans preserves all items inside, they do not rot at all.
@@ -6702,14 +6702,14 @@ bool map::has_rotten_away( item &itm, const tripoint &pnt ) const
// Items inside rot but do not vanish as the container seals them in.
for( auto &c : itm.contents ) {
if( c.goes_bad() ) {
c.process_temperature_rot( 1, pnt, nullptr );
c.process_temperature_rot( 1, pnt, nullptr, flag );
}
}
return false;
} else {
// Check and remove rotten contents, but always keep the container.
for( auto it = itm.contents.begin(); it != itm.contents.end(); ) {
if( has_rotten_away( *it, pnt ) ) {
if( has_rotten_away( *it, pnt, flag ) ) {
it = itm.contents.erase( it );
} else {
++it;
@@ -6723,9 +6723,14 @@ bool map::has_rotten_away( item &itm, const tripoint &pnt ) const
template <typename Container>
void map::remove_rotten_items( Container &items, const tripoint &pnt )
{
const tripoint abs_pnt = getabs( pnt );
temperature_flag flag;
if( ter( pnt ) == t_rootcellar ) {
flag = TEMP_ROOT_CELLAR;
} else {
flag = TEMP_NORMAL;
}
for( auto it = items.begin(); it != items.end(); ) {
if( has_rotten_away( *it, abs_pnt ) ) {
if( has_rotten_away( *it, pnt, flag ) ) {
if( it->is_comestible() ) {
rotten_item_spawn( *it, pnt );
}
+1 -1
View File
@@ -1488,7 +1488,7 @@ class map
* used for rot calculation.
* @return true if the item has rotten away and should be removed, false otherwise.
*/
bool has_rotten_away( item &itm, const tripoint &pnt ) const;
bool has_rotten_away( item &itm, const tripoint &pnt, temperature_flag flag = TEMP_NORMAL ) const;
/**
* Go through the list of items, update their rotten status and remove items
* that have rotten away completely.
+4 -3
View File
@@ -1439,14 +1439,14 @@ class jmapgen_make_rubble : public jmapgen_piece
class jmapgen_computer : public jmapgen_piece
{
public:
std::string name;
translation name;
translation access_denied;
int security;
std::vector<computer_option> options;
std::vector<computer_failure> failures;
bool target;
jmapgen_computer( const JsonObject &jsi ) {
name = jsi.get_string( "name" );
jsi.read( "name", name );
jsi.read( "access_denied", access_denied );
security = jsi.get_int( "security", 0 );
target = jsi.get_bool( "target", false );
@@ -1466,7 +1466,8 @@ class jmapgen_computer : public jmapgen_piece
const int ry = y.get();
dat.m.ter_set( point( rx, ry ), t_console );
dat.m.furn_set( point( rx, ry ), f_null );
computer *cpu = dat.m.add_computer( tripoint( rx, ry, dat.m.get_abs_sub().z ), name, security );
computer *cpu = dat.m.add_computer( tripoint( rx, ry, dat.m.get_abs_sub().z ), name.translated(),
security );
for( const auto &opt : options ) {
cpu->add_option( opt );
}
+13 -11
View File
@@ -916,7 +916,6 @@ void npc::execute_action( npc_action action )
int oldmoves = moves;
tripoint tar = pos();
Creature *cur = current_target();
player *patient = dynamic_cast<player *>( current_ally() );
if( action == npc_flee ) {
tar = good_escape_direction( false );
} else if( cur != nullptr ) {
@@ -1082,18 +1081,21 @@ void npc::execute_action( npc_action action )
}
break;
case npc_heal_player:
update_path( patient->pos() );
if( path.size() == 1 ) { // We're adjacent to u, and thus can heal u
heal_player( *patient );
} else if( !path.empty() ) {
say( _( "Hold still %s, I'm coming to help you." ), patient->disp_name() );
move_to_next();
} else {
move_pause();
case npc_heal_player: {
player *patient = dynamic_cast<player *>( current_ally() );
if( patient ) {
update_path( patient->pos() );
if( path.size() == 1 ) { // We're adjacent to u, and thus can heal u
heal_player( *patient );
} else if( !path.empty() ) {
say( _( "Hold still %s, I'm coming to help you." ), patient->disp_name() );
move_to_next();
} else {
move_pause();
}
}
break;
}
case npc_follow_player:
update_path( g->u.pos() );
if( static_cast<int>( path.size() ) <= follow_distance() &&
+5 -3
View File
@@ -525,18 +525,20 @@ void talk_function::give_equipment( npc &p )
{
std::vector<item_pricing> giving = npc_trading::init_selling( p );
int chosen = -1;
while( chosen == -1 && giving.size() > 1 ) {
while( chosen == -1 && !giving.empty() ) {
int index = rng( 0, giving.size() - 1 );
if( giving[index].price < p.op_of_u.owed ) {
chosen = index;
} else {
giving.erase( giving.begin() + index );
}
giving.erase( giving.begin() + index );
}
if( giving.empty() ) {
popup( _( "%s has nothing to give!" ), p.name );
return;
}
if( chosen == -1 ) {
if( chosen < 0 || static_cast<size_t>( chosen ) >= giving.size() ) {
debugmsg( "Chosen index is outside of available item range!" );
chosen = 0;
}
item it = *giving[chosen].loc.get_item();
+7 -2
View File
@@ -177,9 +177,14 @@ std::vector<item_pricing> npc_trading::init_buying( player &buyer, player &selle
check_item( item_location( seller, &seller.weapon ), 1 );
}
for( map_cursor &cursor : map_selector( seller.pos(), PICKUP_RANGE ) ) {
buy_helper( cursor, check_item );
//nearby items owned by the NPC will only show up in
//the trade window if the NPC is also a shopkeeper
if( np.mission == NPC_MISSION_SHOPKEEP ) {
for( map_cursor &cursor : map_selector( seller.pos(), PICKUP_RANGE ) ) {
buy_helper( cursor, check_item );
}
}
for( vehicle_cursor &cursor : vehicle_selector( seller.pos(), 1 ) ) {
buy_helper( cursor, check_item );
}
+2 -1
View File
@@ -1495,7 +1495,8 @@ void player::on_hit( Creature *source, body_part bp_hit,
} else {
add_msg( m_bad, _( "You lose your balance while being hit!" ) );
}
add_effect( effect_downed, 2_turns );
// This kind of downing is not subject to immunity.
add_effect( effect_downed, 2_turns, num_bp, false, 0, true );
}
}
Character::on_hit( source, bp_hit, 0.0f, proj );
+10
View File
@@ -846,6 +846,16 @@ void overmap::convert_terrain( const std::unordered_map<tripoint, std::string> &
ter_set( pos, oter_id( "house_w_1_east" ) );
} else if( old == "house_base_west" || old == "house_west" ) {
ter_set( pos, oter_id( "house_w_1_west" ) );
} else if( old == "rural_house" || old == "rural_house_north" ) {
ter_set( pos, oter_id( "rural_house1_north" ) );
} else if( old == "rural_house_south" ) {
ter_set( pos, oter_id( "rural_house1_south" ) );
} else if( old == "rural_house_east" ) {
ter_set( pos, oter_id( "rural_house1_east" ) );
} else if( old == "rural_house_west" ) {
ter_set( pos, oter_id( "rural_house1_west" ) );
} else if( old.compare( 0, 10, "mass_grave" ) == 0 ) {
ter_set( pos, oter_id( "field" ) );
}
for( const auto &conv : nearby ) {