static void ReflectionWalkArray(ReflectionContext* context) { const Field* field = context->field; std::vector<byte>& array = *(std::vector<byte>*) context->address; uint16 elementSize = ReflectionArrayGetElementSize(context->field); uint32 arraySize = array.size() / elementSize; context->arraySize = arraySize; context->walkArray(context, ReflectionWalkType::Begin); for(size_t i = 0; i < arraySize; i++) { void* address = (&array[0] + i * elementSize); context->elementAddress = address; if(FieldIsPointer(field) && !ReflectionWalkPointer(context)) continue; Object* object = context->object; Type* type = context->type; context->object = (Object*) context->elementAddress; context->type = field->type; bool isObject = ClassInherits((Class*) context->type, ObjectGetType()); if( isObject ) context->type = ClassGetType(context->object); if( isObject && !context->type ) { LogDebug("Could not get type out of object"); return; } context->walkArray(context, ReflectionWalkType::ElementBegin); ReflectionWalkType(context, context->type); context->walkArray(context, ReflectionWalkType::ElementEnd); context->object = object; context->type = type; } context->walkArray(context, ReflectionWalkType::End); }
/* ConfirmSellItem is called when client recieves ok from server */ T_void StoreConfirmSellItem (T_void) { T_word32 amount; T_byte8 stmp[64]; T_byte8 stmp2[16]; T_3dObject *p_obj; T_inventoryItemStruct *p_inv; DebugRoutine ("StoreConfirmSellItem"); DebugCheck (G_itemToSell != NULL); /* move the item from the store inventory to the player inventory */ // if (G_itemToSell->numitems > 1) // { if (G_itemToSell->itemdesc.type==EQUIP_OBJECT_TYPE_QUIVER) { /* don't make a new item */ /* just add 12 arrows */ Effect (EFFECT_TAKE_AMMO, EFFECT_TRIGGER_GET, G_itemToSell->itemdesc.subtype, 12, 0, G_itemToSell->object); } else { p_obj=ObjectCreateFake(); DebugCheck (p_obj != NULL); ObjectSetType (p_obj,ObjectGetType(G_itemToSell->object)); ObjectSetAngle (p_obj,0x4000); p_inv=InventoryTakeObject (INVENTORY_PLAYER,p_obj); /* set 'quick pointer' for mouse hand */ InventorySetMouseHandPointer (p_inv->elementID); InventoryDoEffect(EFFECT_TRIGGER_GET,EQUIP_LOCATION_MOUSE_HAND); } /* identify arrow type for player */ StatsPlayerIdentify(ObjectGetType(G_itemToSell->object)); /* force mouse hand picture update */ // ControlSetObjectPointer (p_inv->object); // StatsChangePlayerLoad(ObjectGetWeight(G_itemToSell->object)); // G_itemToSell->numitems--; // } // else // { // element=InventoryTransferItemBetweenInventories( // G_itemToSell, // INVENTORY_STORE, // INVENTORY_PLAYER); // DebugCheck (element != DOUBLE_LINK_LIST_ELEMENT_BAD); /* set the mouse hand pointer */ // InventorySetMouseHandPointer (element); // } if (G_houseMode==FALSE) { /* go ahead and sell the item to the player */ /* subtract the cost of this item */ if (EffectPlayerEffectIsActive(PLAYER_EFFECT_GOD_MODE)==FALSE) { amount=ObjectGetValue(G_itemToSell->object); StoreConvertCurrencyToString (stmp,amount); if (G_itemToSell->itemdesc.type==EQUIP_OBJECT_TYPE_QUIVER) { switch (G_itemToSell->itemdesc.subtype) { case BOLT_TYPE_NORMAL: strcpy (stmp2,"normal"); break; case BOLT_TYPE_POISON: strcpy (stmp2,"green"); break; case BOLT_TYPE_PIERCING: strcpy (stmp2,"brown"); break; case BOLT_TYPE_FIRE: strcpy (stmp2,"red"); break; case BOLT_TYPE_ELECTRICITY: strcpy (stmp2,"yellow"); break; case BOLT_TYPE_MANA_DRAIN: strcpy (stmp2,"purple"); break; case BOLT_TYPE_ACID: strcpy (stmp2,"white"); break; default: DebugCheck (0); /* bad bolt! */ break; } MessagePrintf ("^009You bought 12 %s arrows for %s",stmp2,stmp); } else MessagePrintf ("^009Sold!! for %s",stmp); StatsChangePlayerTotalCarriedWealth(-(T_sword32)amount); } else { MessageAdd ("^009Well... You're a god... it's free."); } // StoreUIUpdateGraphics(); } /* resort the inventory */ InventoryReorder (INVENTORY_STORE,TRUE); /* redraw the inventory window */ InventoryDrawInventoryWindow(INVENTORY_STORE); G_itemToSell=NULL; DebugEnd(); }
T_word16 StoreGetBuyValue (T_inventoryItemStruct *p_inv) { T_word16 buyValue=0; T_word16 objtype; DebugRoutine ("StoreGetBuyValue"); if (StoreWillBuy(p_inv->itemdesc.type)) { objtype=ObjectGetType(p_inv->object); if (objtype==60 || objtype==117) { /* bag of gold */ if (ObjectGetAccData(p_inv->object)!=0) { buyValue=ObjectGetAccData(p_inv->object)*100; } else { buyValue=1000; } } else if ((objtype>=110 && objtype<=113) || objtype==56) { /* gems */ buyValue=ObjectGetValue(p_inv->object); } else if (objtype==412 || objtype==413 || objtype==414 || objtype==425 || objtype==433) { /* treasure rings */ buyValue=ObjectGetValue(p_inv->object); } else if (objtype>=144 && objtype<=150) { /* quivers */ if (ObjectGetAccData(p_inv->object)!=0) { buyValue=ObjectGetValue(p_inv->object)* ObjectGetAccData(p_inv->object)/3; } else { buyValue=ObjectGetValue(p_inv->object)/3; } } else if (objtype >= 300 && objtype <= 317) { /* won't buy runes */ buyValue=0; } else { buyValue=(ObjectGetValue(p_inv->object))/3; } } DebugEnd(); return (buyValue); }