/* * Class: java_lang_VMClassRegistry * Method: isAssignableFrom * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z */ JNIEXPORT jboolean JNICALL Java_java_lang_VMClassRegistry_isAssignableFrom (JNIEnv *jenv, jclass, jclass clazz, jclass fromClazz) { // check parameters if (!clazz) { throw_exception_from_jni(jenv, "java/lang/NullPointerException", "clazz argument"); return JNI_FALSE; } if (!fromClazz) { throw_exception_from_jni(jenv, "java/lang/NullPointerException", "fromClazz argument"); return JNI_FALSE; } Class_Handle ch = jni_get_class_handle(jenv, fromClazz); // if primitive class if (ch->is_primitive()) return (jboolean)(IsSameObject(jenv, clazz, fromClazz) ? JNI_TRUE : JNI_FALSE); // if non primitive return IsAssignableFrom(jenv, fromClazz, clazz); }
static HRESULT STDMETHODCALLTYPE ITrayBandSiteImpl_IsTaskBand(IN OUT ITrayBandSite *iface, IN IUnknown *punk) { ITrayBandSiteImpl *This = ITrayBandSiteImpl_from_ITrayBandSite(iface); return IsSameObject((IUnknown *)This->BandSite, punk); }
static HRESULT STDMETHODCALLTYPE ITrayBandSiteImpl_QueryBand(IN OUT IBandSite *iface, IN DWORD dwBandID, OUT IDeskBand **ppstb, OUT DWORD *pdwState, OUT LPWSTR pszName, IN int cchName) { HRESULT hRet; IDeskBand *pstb = NULL; ITrayBandSiteImpl *This = ITrayBandSiteImpl_from_IBandSite(iface); hRet = IBandSite_QueryBand(This->BandSite, dwBandID, &pstb, pdwState, pszName, cchName); if (SUCCEEDED(hRet)) { hRet = IsSameObject((IUnknown *)pstb, (IUnknown *)This->TaskBand); if (hRet == S_OK) { /* Add the BSSF_UNDELETEABLE flag to pdwState because the task bar band shouldn't be deletable */ if (pdwState != NULL) *pdwState |= BSSF_UNDELETEABLE; } else if (!SUCCEEDED(hRet)) { IDeskBand_Release(pstb); pstb = NULL; } if (ppstb != NULL) *ppstb = pstb; } else if (ppstb != NULL) *ppstb = NULL; return hRet; }
void PlayerInventoryHud::dropEntity() { if(!(player.Interface & INTER_INVENTORY) && !(player.Interface & INTER_INVENTORYALL)) return; if(InventoryY != 0) return; if(!g_playerInventoryHud.containsPos(DANAEMouse)) return; Vec2s s = DRAGINTER->m_inventorySize; int bag = 0; Vec2f anchorPos = g_playerInventoryHud.anchorPosition(); float fCenterX = anchorPos.x; float fSizY = anchorPos.y; short iPosX = checked_range_cast<short>(fCenterX); short iPosY = checked_range_cast<short>(fSizY); Vec2s t = Vec2s_ZERO; if(player.Interface & INTER_INVENTORY) { t.x = DANAEMouse.x - iPosX; t.y = DANAEMouse.y - iPosY; t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); if((t.x >= 0) && (t.x <= 16 - s.x) && (t.y >= 0) && (t.y <= 3 - s.y)) { bag = g_currentInventoryBag; } else { return; } } else { bool bOk = false; float fBag = (player.bag - 1) * (-121 * m_scale); short iY = checked_range_cast<short>(fBag); //We must enter the for-loop to initialyze tx/ty arx_assert(0 < player.bag); for(int i = 0; i < player.bag; i++) { t.x = DANAEMouse.x - iPosX; t.y = DANAEMouse.y - iPosY - iY; if((t.x >= 0) && (t.y >= 0)) { t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); if((t.x >= 0) && (t.x <= 16 - s.x) && (t.y >= 0) && (t.y <= 3 - s.y)) { bOk = true; bag = i; break; } } float fRatio = (121 * m_scale); iY += checked_range_cast<short>(fRatio); } if(!bOk) return; } if(DRAGINTER->ioflags & IO_GOLD) { ARX_PLAYER_AddGold(DRAGINTER); Set_DragInter(NULL); return; } for(long j = 0; j < s.y; j++) for(long i = 0; i < s.x; i++) { Entity * ioo = inventory[bag][t.x+i][t.y+j].io; if(!ioo) continue; ARX_INVENTORY_IdentifyIO(ioo); if( ioo->_itemdata->playerstacksize > 1 && IsSameObject(DRAGINTER, ioo) && ioo->_itemdata->count < ioo->_itemdata->playerstacksize ) { ioo->_itemdata->count += DRAGINTER->_itemdata->count; if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) { DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize; ioo->_itemdata->count = ioo->_itemdata->playerstacksize; } else { DRAGINTER->_itemdata->count = 0; } ioo->scale = 1.f; ARX_INVENTORY_Declare_InventoryIn(DRAGINTER); if(!DRAGINTER->_itemdata->count) { DRAGINTER->destroy(); } ARX_SOUND_PlayInterface(SND_INVSTD); return; } return; } for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { inventory[bag][t.x+i][t.y+j].io = DRAGINTER; inventory[bag][t.x+i][t.y+j].show = false; } } inventory[bag][t.x][t.y].show = true; ARX_INVENTORY_Declare_InventoryIn(DRAGINTER); ARX_SOUND_PlayInterface(SND_INVSTD); DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; Set_DragInter(NULL); }
void SecondaryInventoryHud::dropEntity() { // First Look for Identical Item... if(SecondaryInventory && g_secondaryInventoryHud.containsPos(DANAEMouse)) { Entity * io = SecondaryInventory->io; float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; //>>1; long price = checked_range_cast<long>(fprice); price *= DRAGINTER->_itemdata->count; fprice = price + price * player.m_skillFull.intuition * 0.005f; price = checked_range_cast<long>(fprice); // SHOP if(io->ioflags & IO_SHOP) { if(!io->shop_category.empty() && DRAGINTER->groups.find(io->shop_category) == DRAGINTER->groups.end()) return; if(price <= 0) return; // Check shop group for(long j = 0; j < SecondaryInventory->m_size.y; j++) { for(long i = 0; i < SecondaryInventory->m_size.x; i++) { Entity * ioo = SecondaryInventory->slot[i][j].io; if(!ioo || !IsSameObject(DRAGINTER, ioo)) continue; ioo->_itemdata->count += DRAGINTER->_itemdata->count; ioo->scale = 1.f; DRAGINTER->destroy(); ARX_PLAYER_AddGold(price); ARX_SOUND_PlayInterface(SND_GOLD); ARX_SOUND_PlayInterface(SND_INVSTD); return; } } } Vec2s t = Vec2s_ZERO; t.x = DANAEMouse.x + static_cast<short>(m_fadePosition) - (2 * m_scale); t.y = DANAEMouse.y - (13 * m_scale); t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); Vec2s s = DRAGINTER->m_inventorySize; if(t.x <= SecondaryInventory->m_size.x - s.x && t.y <= SecondaryInventory->m_size.y - s.y) { float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; long price = checked_range_cast<long>(fprice); price *= DRAGINTER->_itemdata->count; fprice = price + price * player.m_skillFull.intuition * 0.005f; price = checked_range_cast<long>(fprice); for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { Entity * ioo = SecondaryInventory->slot[t.x+i][t.y+j].io; if(!ioo) continue; DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; if( ioo->_itemdata->playerstacksize > 1 && IsSameObject(DRAGINTER, ioo) && ioo->_itemdata->count < ioo->_itemdata->playerstacksize ) { ioo->_itemdata->count += DRAGINTER->_itemdata->count; if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) { DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize; ioo->_itemdata->count = ioo->_itemdata->playerstacksize; } else { DRAGINTER->_itemdata->count = 0; } } if(DRAGINTER->_itemdata->count) { if(CanBePutInSecondaryInventory(SecondaryInventory, DRAGINTER)) { // SHOP if(io->ioflags & IO_SHOP) { ARX_PLAYER_AddGold(price); ARX_SOUND_PlayInterface(SND_GOLD); } } else { return; } } ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(NULL); return; } } if(DRAGINTER->ioflags & IO_GOLD) { ARX_PLAYER_AddGold(DRAGINTER); Set_DragInter(NULL); return; } for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { SecondaryInventory->slot[t.x+i][t.y+j].io = DRAGINTER; SecondaryInventory->slot[t.x+i][t.y+j].show = false; } } // SHOP if(io->ioflags & IO_SHOP) { player.gold += price; ARX_SOUND_PlayInterface(SND_GOLD); } SecondaryInventory->slot[t.x][t.y].show = true; DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(NULL); return; } } }
USER_OBJECT_ RS_JAVA(MethodConverter)(jobject obj, jclass type, JNIEnv *env, RSFromJavaConverter *converter) { int i = 0, k, n; int numSlots; USER_OBJECT_ ans, names; const char *tmp; jboolean isCopy; jstring jval; jclass klass; jobject jsig, jobj; ReflectanceMethodIDs *mids; boolean isMethod; jint modifier; if(ModifierStringID == NULL) initReflectanceMethods(env); /* Determine whether we have a constructor or method and set the method identifiers and number of slots appropriately. */ isMethod = VMENV IsSameObject(env, type, VMENV FindClass(env, "java/lang/reflect/Method")) == JNI_TRUE; if(isMethod) { mids = &MethodIDs; numSlots = 6; } else { mids = &ConstructorIDs; numSlots = 5; /* Drop out the */ } PROTECT(ans = NEW_LIST(numSlots)); PROTECT(names = NEW_CHARACTER(numSlots)); SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1)); jval = VMENV CallObjectMethod(env, obj, mids->getName); tmp = VMENV GetStringUTFChars(env, jval, &isCopy); SET_STRING_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp)); if(isCopy) VMENV ReleaseStringUTFChars(env, jval, tmp); SET_STRING_ELT(names, i, COPY_TO_USER_STRING("name")); i++; SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1)); klass = VMENV CallObjectMethod(env, obj, mids->getClass); tmp = getClassName(env, klass, &isCopy); SET_STRING_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp)); SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Declaring class")); i++; jsig = VMENV CallObjectMethod(env, obj, mids->getParameters); n = VMENV GetArrayLength(env, jsig); SET_VECTOR_ELT(ans, i, NEW_CHARACTER(n)); for(k = 0; k < n ; k++) { jobj = VMENV GetObjectArrayElement(env, jsig, k); tmp = getClassName(env, jobj, &isCopy); SET_STRING_ELT(VECTOR_ELT(ans, i), k, COPY_TO_USER_STRING(tmp)); } SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Parameters")); i++; SET_VECTOR_ELT(ans, i, NEW_INTEGER(1)); modifier = VMENV CallIntMethod(env, obj, mids->getModifiers); INTEGER_DATA(VECTOR_ELT(ans, i))[0] = modifier; SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Modifiers")); { /* Now get the string that represents the modifier value. Do this by calling the static method toString(int) in the java.lang.reflect.Modifier class. We assume we have initialized the ModifierStringID method id earlier when getting all the method ids for the reflectance classes. */ USER_OBJECT_ tmpr; const char *modName; jstring jmodName; PROTECT(tmpr = NEW_CHARACTER(1)); jmodName = VMENV CallStaticObjectMethod(env, (jclass)VMENV FindClass(env, "java/lang/reflect/Modifier"), ModifierStringID, modifier); if(jmodName != NULL_JAVA_OBJECT) { modName = VMENV GetStringUTFChars(env, jmodName, &isCopy); SET_STRING_ELT(tmpr, 0, COPY_TO_USER_STRING(modName)); } SET_NAMES(VECTOR_ELT(ans, i), tmpr); UNPROTECT(1); } i++; jsig = VMENV CallObjectMethod(env, obj, mids->getExceptions); n = VMENV GetArrayLength(env, jsig); SET_VECTOR_ELT(ans, i, NEW_CHARACTER(n)); for(k = 0; k < n ; k++) { jobj = VMENV GetObjectArrayElement(env, jsig, k); tmp = getClassName(env, jobj, &isCopy); SET_STRING_ELT(VECTOR_ELT(ans, i), k, COPY_TO_USER_STRING(tmp)); } SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Exceptions")); i++; if(isMethod) { SET_VECTOR_ELT(ans, i, NEW_CHARACTER(1)); klass = VMENV CallObjectMethod(env, obj, mids->getReturnType); tmp = getClassName(env, klass, &isCopy); SET_VECTOR_ELT(VECTOR_ELT(ans, i), 0, COPY_TO_USER_STRING(tmp)); SET_STRING_ELT(names, i, COPY_TO_USER_STRING("Return type")); i++; } SET_NAMES(ans, names); /* Now set the class to be "JavaMethod" */ UNPROTECT(2); return(ans); }