Example #1
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Action
///////////////////////////////////////////////////////////////////////////////////////////////////////////
void Action()
{
	Object::iterator oIter;
	for (oIter = g_Object.begin(); oIter != g_Object.end(); )
	{
		CBaseObject *pBaseObject = (*oIter);
		
		if (!pBaseObject->Action(pBaseObject->GetObjectID()))	oIter++;
		else
		{
			delete pBaseObject;
			g_Object.erase(oIter++);
		}

		WriteProc();
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////
	// TileMap 좌표 지정
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	if (g_pPlayerObject != NULL)
		g_cTileMap.SetDrawPos(g_pPlayerObject->GetCurX(), g_pPlayerObject->GetCurY());

	//y축 정렬 시키기
	//이펙트는 제일 뒤로 밀기
}
Example #2
0
void Json::Copy(const Json& json){
	_kind = json._kind;
	switch(json._kind){
	case kNull: {  _data = NULL; break;}
	case kNumber: {  _data = new double(json.GetDouble()); break; } 
	case kString: {  _data = new std::string(json.GetString()); break; }
	case kTrue: case kFalse: { _data = new bool(json.GetBool());break;  }
	case kArray: 
		{
			Array * thisArr = new Array;
			Array& arr = *(Array*)json._data;
			for(Array::iterator it = arr.begin(); it != arr.end(); it++){
				thisArr->push_back(new Json(*(*it)) );
			}
			_data = thisArr;
			break;
		}
	case kObject: 
		{
			Object* thisObj = new Object;
			Object& obj = *(Object*)json._data;
			for(Object::iterator it = obj.begin(); it != obj.end(); it++){
				Pair p;
				p.first = it->first; 
				p.second = new Json(*(it->second));
				thisObj->insert(p);
			}
			_data = thisObj;
			break;
		}
	default: break;
	}
}
Example #3
0
Object JSONRPCError(int code, const string& message)
{
    Object error;
    error.push_back(Pair("code", code));
    error.push_back(Pair("message", message));
    return error;
}
void Functions::getMaxHitPoints(Aurora::NWScript::FunctionContext &ctx) {
	Aurora::NWScript::Object *object = ctx.getParams()[0].getObject();

	Object *kotorObject = ObjectContainer::toObject(object);

	ctx.getReturn() = kotorObject ? kotorObject->getMaxHitPoints() : 0;
}
size_t
ObjectContainerBSDArchive::Archive::ParseObjects ()
{
    DataExtractor &data = m_data;
    std::string str;
    lldb::offset_t offset = 0;
    str.assign((const char *)data.GetData(&offset, SARMAG), SARMAG);
    if (str == ARMAG)
    {
        Object obj;
        do
        {
            offset = obj.Extract (data, offset);
            if (offset == LLDB_INVALID_OFFSET)
                break;
            size_t obj_idx = m_objects.size();
            m_objects.push_back(obj);
            // Insert all of the C strings out of order for now...
            m_object_name_to_index_map.Append (obj.ar_name.GetCString(), obj_idx);
            offset += obj.ar_file_size;
            obj.Clear();
        } while (data.ValidOffset(offset));

        // Now sort all of the object name pointers
        m_object_name_to_index_map.Sort ();
    }
    return m_objects.size();
}
Example #6
0
  void Tuple::Info::show_simple(STATE, Object* self, int level) {
    Tuple* tup = as<Tuple>(self);
    native_int size = tup->num_fields();
    native_int stop = size < 6 ? size : 6;

    if(size == 0) {
      class_info(state, self, true);
      return;
    }

    class_info(state, self);
    std::cout << ": " << size << std::endl;
    ++level;
    for(native_int i = 0; i < stop; i++) {
      indent(level);
      Object* obj = tup->at(state, i);
      if(Tuple* t = try_as<Tuple>(obj)) {
        class_info(state, self);
        std::cout << ": " << t->num_fields() << ">" << std::endl;
      } else {
        obj->show_simple(state, level);
      }
    }
    if(tup->num_fields() > stop) ellipsis(level);
    close_body(level);
  }
Example #7
0
void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recvData)
{
    uint64 guid;
    uint32 questId;
    uint8 unk1;
    recvData >> guid >> questId >> unk1;
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u, unk1 = %u", uint32(GUID_LOPART(guid)), questId, unk1);

    // Verify that the guid is valid and is a questgiver or involved in the requested quest
    Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM);
    if (!object || (!object->hasQuest(questId) && !object->hasInvolvedQuest(questId)))
    {
        _player->PlayerTalkClass->SendCloseGossip();
        return;
    }

    if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
    {
        // not sure here what should happen to quests with QUEST_FLAGS_AUTOCOMPLETE
        // if this breaks them, add && object->GetTypeId() == TYPEID_ITEM to this check
        // item-started quests never have that flag
        if (!_player->CanTakeQuest(quest, true))
            return;

        if (quest->IsAutoAccept() && _player->CanAddQuest(quest, true))
            _player->AddQuestAndCheckCompletion(quest, object);

        if (quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
            _player->PlayerTalkClass->SendQuestGiverRequestItems(quest, object->GetGUID(), _player->CanCompleteQuest(quest->GetQuestId()), true);
        else
            _player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, object->GetGUID(), true);
    }
}
Example #8
0
void ObjectAccessor::Update(uint32 /*diff*/)
{
    UpdateDataMapType update_players;

    // Critical section
    {
        ACE_GUARD(LockType, g, i_updateGuard);

        while (!i_objects.empty())
        {
            Object* obj = *i_objects.begin();
            ASSERT(obj && obj->IsInWorld());
            i_objects.erase(i_objects.begin());
            obj->BuildUpdate(update_players);
        }
    }

    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
    for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
    {
        iter->second.BuildPacket(&packet);
        iter->first->GetSession()->SendPacket(&packet);
        packet.clear();                                     // clean the string
    }
}
Example #9
0
	bool OnGossipHello(Player* pPlayer, Creature* pCreature)
	{
		// uint64 const guid = pCreature->GetGUID();

		if (pCreature->isQuestGiver())
		{
			Object *pObject = (Object*)pCreature;
			QuestRelations* pObjectQR = sObjectMgr->GetCreatureQuestRelationMap();
			QuestRelations* pObjectQIR = sObjectMgr->GetCreatureQuestInvolvedRelation();

			QuestMenu &qm = pPlayer->PlayerTalkClass->GetQuestMenu();
			qm.ClearMenu();

			for (QuestRelations::const_iterator i = pObjectQIR->lower_bound(pObject->GetEntry()); i != pObjectQIR->upper_bound(pObject->GetEntry()); ++i)
			{
				uint32 quest_id = i->second;
				QuestStatus status = pPlayer->GetQuestStatus(quest_id);
				if (status == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(quest_id))
					qm.AddMenuItem(quest_id, 4);
				else if (status == QUEST_STATUS_INCOMPLETE)
					qm.AddMenuItem(quest_id, 4);
				//else if (status == QUEST_STATUS_AVAILABLE)
				//    qm.AddMenuItem(quest_id, 2);
			}

		for (QuestRelations::const_iterator i = pObjectQR->lower_bound(pObject->GetEntry()); i != pObjectQR->upper_bound(pObject->GetEntry()); ++i)
			{
				uint32 quest_id = i->second;
				Quest const* pQuest = sObjectMgr->GetQuestTemplate(quest_id);
				if (!pQuest) continue;
				QuestStatus status;
				bool allowed=false;
				switch(quest_id)
				{
					case 13795: // The Scourgebane
						allowed = (pPlayer->GetQuestStatus(13702) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13702)) || (pPlayer->GetQuestStatus(13732) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13732)) || (pPlayer->GetQuestStatus(13735) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13735)) || (pPlayer->GetQuestStatus(13733) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13733)) || (pPlayer->GetQuestStatus(13734) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13734)) || (pPlayer->GetQuestStatus(13736) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13736)) || (pPlayer->GetQuestStatus(13737) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13737)) || (pPlayer->GetQuestStatus(13738) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13738)) || (pPlayer->GetQuestStatus(13739) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13739)) || (pPlayer->GetQuestStatus(13740) == QUEST_STATUS_COMPLETE && pPlayer->GetQuestRewardStatus(13740)); // If the player has finished any of the "A Champion Rises" quests
						if(allowed)
						{
							status = pPlayer->GetQuestStatus(quest_id);

							if(pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false))
								qm.AddMenuItem(quest_id, 4);
							else if(status == QUEST_STATUS_NONE && pPlayer->CanTakeQuest(pQuest, false))
								qm.AddMenuItem(quest_id, 2);
						}
						break;
					default:
						status = pPlayer->GetQuestStatus(quest_id);

						if (pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false))
							qm.AddMenuItem(quest_id, 4);
						else if (status == QUEST_STATUS_NONE && pPlayer->CanTakeQuest(pQuest, false))
							qm.AddMenuItem(quest_id, 2);
						break;
				}
			}
		}
	    pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
	    return true;
	}
Example #10
0
  Object* run_instance(STATE) {
    /* These are all referenced, so OnStack is not necessary. Additionally,
     * thread is pinned, so we do not need to worry about it moving.
     */
    Thread* thread = state->vm()->thread.get();
    Array* args = thread->args();
    Object* block = thread->block();

    if(thread->initialized()->false_p() || args->nil_p() || block->nil_p()) {
      return cNil;
    }

    Object* value = block->send(state, G(sym_call), args, block);

    /* We explicitly set the current CallFrame reference to NULL because we
     * are at the top of the stack in terms of managed code.
     */
    state->vm()->set_call_frame(NULL);

    thread->exception(state, state->vm()->thread_state()->current_exception());

    if(state->vm()->thread_state()->raise_reason() == cThreadKill) {
      thread->value(state, cNil);
    } else if(value) {
      thread->value(state, value);
    }

    Object* mirror = G(mirror)->send(state, state->symbol("reflect"),
        Array::from_tuple(state, Tuple::from(state, 1, thread)));
    mirror->send(state, state->symbol("finish"));

    return value;
  }
Example #11
0
static int js_atomic_destroy(duk_context* ctx)
{
    if (!duk_is_object(ctx, 0))
        return 0;

    Object* obj = js_to_class_instance<Object>(ctx, 0, 0);

    if (!obj)
        return 0;

    if (obj->GetType() == Node::GetTypeStatic())
    {
        Node* node = (Node*) obj;
        js_atomic_destroy_node(node, ctx, true);
        return 0;
    }
    if (obj->GetType() == Scene::GetTypeStatic())
    {
        Scene* scene = (Scene*) obj;
        js_atomic_destroy_scene(scene, ctx);
        return 0;
    }
    else if (obj->GetType() == JSComponent::GetTypeStatic())
    {
        // FIXME: want to be able to destroy a single component
        assert(0);
        JSComponent* component = (JSComponent*) obj;
        component->UnsubscribeFromAllEvents();
        component->Remove();
        return 0;
    }

    return 0;
}
Example #12
0
Intersection * intersectElement (R3Vector u, R3Vector p0, bool intersectLights)
{
    Intersection * nearestIntersection = NULL;
    double NIDistance = MAX_DEPTH * MAX_DEPTH;
    for (unsigned int i = 0; i < objs.size (); i++)
    {
        Object * object = objs[i];
        Intersection * intersection = object->intersect (u, p0);
        
        // If intersects nothing or intersects a light (and we are avoiding lights)
        // go to the next object
        if (intersection == NULL || 
           (!intersectLights && intersection->object->isLight ()))
            continue;

        double intDistance;
        R3Vector p0ToInt = intersection->point;
        p0ToInt.x = p0.x - p0ToInt.x;
        p0ToInt.y = p0.y - p0ToInt.y;
        p0ToInt.z = p0.z - p0ToInt.z;
        intDistance = norm (p0ToInt);

        if (nearestIntersection == NULL || intDistance - 1e-5 < NIDistance)
        {
            nearestIntersection = intersection;
            NIDistance = intDistance;
        }

    }
    return nearestIntersection;
}
Example #13
0
  Object* VM::new_object_typed_dirty(Class* cls, size_t size, object_type type) {
    State state(this);

    if(unlikely(size > om->large_object_threshold)) {
      return om->new_object_typed_enduring_dirty(&state, cls, size, type);
    }

    Object* obj = local_slab().allocate(size).as<Object>();

    if(unlikely(!obj)) {
      if(shared.om->refill_slab(&state, local_slab())) {
        obj = local_slab().allocate(size).as<Object>();
      }

      // If refill_slab fails, obj will still be NULL.

      if(!obj) {
        return om->new_object_typed_dirty(&state, cls, size, type);
      }
    }

    obj->init_header(cls, YoungObjectZone, type);

    return obj;
  }
Example #14
0
Object GetObjectFromSignature(Signature signature)
{
    Object object;
    object.push_back(Pair("exhibit", signature.exhibit.ToString()));
    object.push_back(Pair("signature", signature.signature.ToString()));
    return object;
}
Example #15
0
void VariantToBsonConverter::_convertRegex(bson_t *bson, const char *key, Object v)
{
	String regex = v.o_get(s_MongoBsonRegex_pattern, false, s_MongoBsonRegex_className).toString();
	String flags = v.o_get(s_MongoBsonRegex_flags, false, s_MongoBsonRegex_className).toString();

	bson_append_regex(bson, key, -1, regex.c_str(), flags.c_str());
}
BOOL PFOperatorInstanceShapeMXSValidator::Validate(PB2Value& v)
{
	INode* iNode = (INode*)v.r;
	if (iNode == NULL) return NULL;
	TimeValue t = GetCOREInterface()->GetTime();
	Tab<INode*> stack;

	stack.Append(1, &iNode, 10);
	while (stack.Count())
	{
		INode *node = stack[stack.Count()-1];
		stack.Delete(stack.Count()-1, 1);

		Object *obj = node->EvalWorldState(t).obj;
		if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
			return TRUE;

		// add children to the stack
		for (int i = 0; i < node->NumberOfChildren(); i++) {
			INode *childNode = node->GetChildNode(i);
			if (childNode)	stack.Append(1, &childNode, 10);
		}
	}
	return FALSE;
}
Example #17
0
void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket & recv_data)
{
    CHECK_PACKET_SIZE(recv_data,8+4);

    uint32 quest;
    uint64 guid;
    recv_data >> guid >> quest;

    if (!GetPlayer()->isAlive())
        return;

    sLog.outDebug("WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %u, quest = %u",uint32(GUID_LOPART(guid)),quest);

    Object* pObject = _player->GetMap()->GetObjectByTypeMask(*_player, guid,TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
    if (!pObject||!pObject->hasInvolvedQuest(quest))
        return;

    if (_player->CanCompleteQuest(quest))
        _player->CompleteQuest(quest);

    if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE)
        return;

    if (Quest const *pQuest = sObjectMgr.GetQuestTemplate(quest))
        _player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true);
}
Example #18
0
void Body2DSW::call_queries() {


	if (fi_callback) {

		Physics2DDirectBodyStateSW *dbs = Physics2DDirectBodyStateSW::singleton;
		dbs->body=this;

		Variant v=dbs;
		const Variant *vp[2]={&v,&fi_callback->callback_udata};


		Object *obj = ObjectDB::get_instance(fi_callback->id);
		if (!obj) {

			set_force_integration_callback(0,StringName());
		} else {
			Variant::CallError ce;			
			if (fi_callback->callback_udata.get_type()) {

				obj->call(fi_callback->method,vp,2,ce);

			} else {
				obj->call(fi_callback->method,vp,1,ce);
			}
		}


	}

}
Example #19
0
//
// The fast paths for object allocation and write barriers is performance critical. They are often
// hand written in assembly code, etc.
//
Object * AllocateObject(MethodTable * pMT)
{
    alloc_context * acontext = GetThread()->GetAllocContext();
    Object * pObject;

    size_t size = pMT->GetBaseSize();

    BYTE* result = acontext->alloc_ptr;
    BYTE* advance = result + size;
    if (advance <= acontext->alloc_limit)
    {
        acontext->alloc_ptr = advance;
        pObject = (Object *)result;
    }
    else
    {
        pObject = GCHeap::GetGCHeap()->Alloc(acontext, size, 0);
        if (pObject == NULL)
            return NULL;
    }

    pObject->SetMethodTable(pMT);

    return pObject;
}
Example #20
0
void EditorResourcePreview::_preview_ready(const String& p_str,const Ref<Texture>& p_texture,ObjectID id,const StringName& p_func,const Variant& p_ud) {

	//print_line("preview is ready");
	preview_mutex->lock();

	String path = p_str;
	uint32_t hash=0;
	uint64_t modified_time=0;

	if (p_str.begins_with("ID:")) {
		hash=p_str.get_slicec(':',2).to_int();
		path="ID:"+p_str.get_slicec(':',1);
	} else {
		modified_time = FileAccess::get_modified_time(path);
	}

	Item item;
	item.order=order++;
	item.preview=p_texture;
	item.last_hash=hash;
	item.modified_time=modified_time;

	cache[path]=item;

	Object *recv = ObjectDB::get_instance(id);
	if (recv) {
		recv->call_deferred(p_func,path,p_texture,p_ud);
	}

	preview_mutex->unlock();
}
Example #21
0
void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket& recvData)
{
    uint32 questId;
    uint64 guid;
    recvData >> guid >> questId;

    TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %u, quest = %u", uint32(GUID_LOPART(guid)), questId);

    Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
    if (!object || !object->hasInvolvedQuest(questId))
        return;

    // some kind of WPE protection
    if (!_player->CanInteractWithQuestGiver(object))
        return;

    if (_player->CanCompleteQuest(questId))
        _player->CompleteQuest(questId);

    if (_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE)
        return;

    if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
        _player->PlayerTalkClass->SendQuestGiverOfferReward(quest, guid, true);
}
Example #22
0
//erase object's current render on console, and update position based on speed in X and Y
void QuadtreeNode::updateObject()
{
	if (nw) 
	{
		nw->updateObject();
		ne->updateObject();
		sw->updateObject();
		se->updateObject();
	}
	for (unsigned int i = 0; i < nodeObjectVector.size(); ++i)
	{
		Object *obj = nodeObjectVector[i];
		if (!obj->first)
		{
			//obj->erase();
			if (!obj->collision)
			{
				obj->update();
			}
		}
		else
		{
			//object just initialized, do not need to erase and update position
			obj->first = false;
		}
	}
}
Example #23
0
void Window::load() {
	// Generate light source:
	Matrix4 temp;
	temp.identity();
	setMatrix(temp);
	glEnable(GL_LIGHTING);

	camera.set(e, d, up);
	object.move(0, 1, 0);
	cameraObject.set(initial.get(0),initial.get(1),initial.get(2));
	bCurve.setPoints(initial, Vector4(-2, 8, -4, 0), Vector4(2, 8, 4, 0), endV);
	for (int i = 0; i < 100; i++) {
		points[i] = bCurve.evalBCurve((double)i / 100);
	}
	belzCamera.set(points[0], belzD, belzUp);
	loadTextures();
	loadCharacter();
	Vector4 points[49];
	for (int i = 0; i < 7; i++) {
		for (int j = 0; j < 7; j++) {
			int k = i * 7 + j;
			points[k] = Vector4((double)i*2 - 6, (double)10, (double)j*2 - 6, 0);
		}
	}
	plane.definePoints(points);
}
Example #24
0
void MarkObjectAndChildren(Object const &Q, bool M)
{
	if (!Q.Exists())
		return;

	MarkObjectAndChildren(Q.GetStorageBase(), M);
}
Example #25
0
void Json::FreeMemory(){
	switch(_kind){
	case kNumber: { double* ptr = (double*)_data; delete ptr; break; }
	case kString: { std::string* ptr = (std::string*)_data; delete ptr; break; }
	case kFalse: case kTrue: { bool* ptr = (bool*)_data; delete ptr; break; }
	case kArray: 
		{
			Array& arr = *(Array*)_data;
			Array::iterator iter = arr.begin();
			for(; iter != arr.end(); iter++){
				delete *iter;
				*iter = NULL;
			}
			break;
		}
	case kObject:
		{
			Object* obj = (Object*)_data;
			Object::iterator iter = obj->begin();
			for(; iter != obj->end(); iter++){
				delete iter->second;
				iter->second = NULL;
			}
			break;
		}
	default: break;
	}
	_data = NULL;
	_kind = kNull;
}
Example #26
0
void *Object_new(size_t size, Object proto, char *description)
{
  // setup the default functions in case they aren't set
  if (!proto.init) proto.init = Object_init;
  if (!proto.describe) proto.describe = Object_describe;
  if (!proto.destroy) proto.destroy = Object_destroy;
  if (!proto.attack) proto.attack = Object_attack;
  if (!proto.move) proto.move = Object_move;

  // this seems weird, but we can make a struct of one size,
  // then point a different pointer at it to "cast" it
  Object *el = calloc(1, size);
  *el = proto;

  // copy the description over
  el->description = strdup(description);

  // initialize it with whatever init we were give
  if (!el->init(el)) {
    el->destroy(el);
    return NULL;
  } else {
    // all done, we made an object of any type
    return el;
  }
}
Example #27
0
 std::tuple<bool, ObjectRepositoryItem> Create([[maybe_unused]] int32_t language, const std::string& path) const override
 {
     Object* object = nullptr;
     auto extension = Path::GetExtension(path);
     if (String::Equals(extension, ".json", true))
     {
         object = ObjectFactory::CreateObjectFromJsonFile(_objectRepository, path);
     }
     else if (String::Equals(extension, ".parkobj", true))
     {
         object = ObjectFactory::CreateObjectFromZipFile(_objectRepository, path);
     }
     else
     {
         object = ObjectFactory::CreateObjectFromLegacyFile(_objectRepository, path.c_str());
     }
     if (object != nullptr)
     {
         ObjectRepositoryItem item = {};
         item.ObjectEntry = *object->GetObjectEntry();
         item.Path = path;
         item.Name = object->GetName();
         item.Sources = object->GetSourceGames();
         object->SetRepositoryItem(&item);
         delete object;
         return std::make_tuple(true, item);
     }
     return std::make_tuple(false, ObjectRepositoryItem());
 }
Example #28
0
/* {{{ MongoDriver\BSON\Binary */
void VariantToBsonConverter::_convertBinary(bson_t *bson, const char *key, Object v)
{
	String data = v.o_get(s_MongoBsonBinary_data, false, s_MongoBsonBinary_className).toString();
	int64_t type = v.o_get(s_MongoBsonBinary_type, false, s_MongoBsonBinary_className).toInt64();

	bson_append_binary(bson, key, -1, (bson_subtype_t) type, (const unsigned char*) data.c_str(), data.length());
}
Example #29
0
Value getrawtransaction(const Array& params, bool fHelp)
{
    if (fHelp || params.size() < 1 || params.size() > 2)
        throw runtime_error(
            "getrawtransaction <txid> [verbose=0]\n"
            "If verbose=0, returns a string that is\n"
            "serialized, hex-encoded data for <txid>.\n"
            "If verbose is non-zero, returns an Object\n"
            "with information about <txid>.");

    uint256 hash = ParseHashV(params[0], "parameter 1");

    bool fVerbose = false;
    if (params.size() > 1)
        fVerbose = (params[1].get_int() != 0);

    CTransaction tx;
    uint256 hashBlock = 0;
    if (!GetTransaction(hash, tx, hashBlock, true))
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");

    CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
    ssTx << tx;
    string strHex = HexStr(ssTx.begin(), ssTx.end());

    if (!fVerbose)
        return strHex;

    Object result;
    result.push_back(Pair("hex", strHex));
    TxToJSON(tx, hashBlock, result);
    return result;
}
Example #30
0
static uint64_t getNextRVA(const Object &Obj) {
  if (Obj.getSections().empty())
    return 0;
  const Section &Last = Obj.getSections().back();
  return alignTo(Last.Header.VirtualAddress + Last.Header.VirtualSize,
                 Obj.IsPE ? Obj.PeHeader.SectionAlignment : 1);
}