예제 #1
0
파일: kalloc.c 프로젝트: chain78/none
void kfree_s(void *obj,unsigned int size){
    void    *page;
    struct _bucket_dir *bdir;
    Bucket  *bdesc,*prev;

    page = (void *)(get_pointer((Pointer)obj));

    for(bdir = bucket_dir;bdir->size;bdir++){
        prev = NULL;
        if(bdir->size < size) continue;
        for(bdesc = bdir->bucket;bdesc;bdesc = bdesc->next){
            if(bdesc->page == page)
                goto found;
            prev = bdesc;
        }
    }
    panic("Bad address passed to kernel free_s()");
found:
    lock();
    *((void **)obj) = bdesc->freeptr;
    bdesc->refcnt--;
    if(bdesc->refcnt == 0){
        if((prev && (prev->next != bdesc)) || (!prev && (bdir->bucket != bdesc)))
            for(prev = bdir->bucket;prev;prev = prev->next)
                if(prev->next == bdesc)
                    break;
        if(prev)
            prev->next = bdesc->next;
        else{
            if(bdir->bucket != bdesc)
                panic("malloc bucket corrupted\n");
            bdir->bucket = bdesc->next;
        }
        free_page((Pointer)bdesc->page);
        bdesc->next = free_bucket;
        free_bucket = bdesc;
    }
    unlock();
}
예제 #2
0
static void
generate_focus_event (GdkWindow *window, gboolean focused)
{
  GdkEvent *event;

  if (focused)
    {
      gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
      _gdk_mir_display_focus_window (gdk_window_get_display (window), window);
    }
  else
    {
      gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
      _gdk_mir_display_unfocus_window (gdk_window_get_display (window), window);
    }

  event = gdk_event_new (GDK_FOCUS_CHANGE);
  event->focus_change.send_event = FALSE;
  event->focus_change.in = focused;

  send_event (window, get_pointer (window), event);
}
예제 #3
0
bool SECTREE::InsertEntity(LPENTITY pkEnt)
{
	LPSECTREE pkCurTree;

	if ((pkCurTree = pkEnt->GetSectree()) == this)
		return false;

	if (m_set_entity.find(pkEnt) != m_set_entity.end()) {
		sys_err("entity %p already exist in this sectree!", get_pointer(pkEnt));
		return false;
	}

	if (pkCurTree)
		pkCurTree->m_set_entity.erase(pkEnt);

	pkEnt->SetSectree(this);
	//pkEnt->UpdateSectree();

	m_set_entity.insert(pkEnt);

	if (pkEnt->IsType(ENTITY_CHARACTER))
	{
		LPCHARACTER pkChr = (LPCHARACTER) pkEnt;

		if (pkChr->IsPC())
		{
			IncreasePC();

			if (pkCurTree)
				pkCurTree->DecreasePC();
		}
		else if (m_iPCCount > 0 && !pkChr->IsWarp() && !pkChr->IsGoto()) // PC가 아니고 이 곳에 PC가 있다면 Idle event를 시작 시킨다.
		{
			pkChr->StartStateMachine();
		}
	}

	return true;
}
예제 #4
0
/*
 * Handles the return from a 68k call at the emulator's side.
 */
static uae_u32 REGPARAM2 m68k_return_handler (struct regstruct *regs)
{
    ExtendedTrapContext *context;
    uae_u32 sp;

    /* One trap returning at a time, please! */
    uae_sem_wait (&trap_mutex);

    /* Get trap context from 68k stack. */
    sp = m68k_areg (regs, 7);
    context = (struct ExtendedTrapContext *) get_pointer(sp);
    sp += sizeof (void *);
    m68k_areg (regs, 7) = sp;

    /* Get return value from the 68k call. */
    context->call68k_retval = m68k_dreg (regs, 0);

    /* Update trap's working copy of CPU state. */
    context->regs = *regs;

    /* Switch back to trap context. */
    uae_sem_post (&context->switch_to_trap_sem);

    /* Wait for trap context to switch back to us.
     *
     * It'll do this when the trap handler is done - or when
     * the handler wants to call another 68k function. */
    uae_sem_wait (&context->switch_to_emu_sem);

    /* Use trap's modified 68k state. This will reset the PC, so that
     * execution will resume at either the m68k call handler or the
     * the exit handler. */
    *regs = context->regs;

    /* Dummy return value. */
    return 0;
}
예제 #5
0
파일: war_map.cpp 프로젝트: adi97ida/Server
void CWarMap::AddFlag(BYTE bIdx, DWORD x, DWORD y)
{
	if (m_bEnded)
		return;

	assert(bIdx < 2);

	TeamData & r = m_TeamData[bIdx];

	if (r.pkChrFlag)
		return;

	if (x == 0)
	{
		x = m_kMapInfo.posStart[bIdx].x;
		y = m_kMapInfo.posStart[bIdx].y;
	}

	r.pkChrFlag = CHARACTER_MANAGER::instance().SpawnMob(bIdx == 0 ? warmap::WAR_FLAG_VNUM0 : warmap::WAR_FLAG_VNUM1, m_kMapInfo.lMapIndex, x, y, 0);
	sys_log(0, "WarMap::AddFlag %u %p id %u", bIdx, get_pointer(r.pkChrFlag), r.dwID);

	r.pkChrFlag->SetPoint(POINT_STAT, r.dwID);
	r.pkChrFlag->SetWarMap(this);
}
예제 #6
0
// If free==0, no new tables will be constructed.
// page_size indicates the size of a page.
// For VADDR_LSO 12 and PT_INDEX_WIDTH 9, this means:
// page_size=0 --> 4KiB
// page_size=1 --> 2MiB
// page_size=2 --> 1GiB
//MLDTODO Rewrite with section nomenclature
int write_entry(pt_t* pt0, uint64_t pts_index, void* dst, unsigned page_size, pt_t** next_table, size_t *free, uint8_t r, uint8_t w, uint8_t x){
	pt_t*  table = pt0;
	pte_t* entry;

	int min = page_size;
	int max = PTS_INDEX_WIDTH / PT_INDEX_WIDTH;

	for(int i=max-1; i>=min; i--){
		uint64_t pt_index = get_index_section(pts_index, i);
		entry = &(table->entries[pt_index]);
		if(i == min){
			if(entry->p){ return -32; }

			table = construct_pt(next_table);
			*free -= 1;

			entry->p = 1;
			entry->t = 0;
			entry->page_p.r = r;
			entry->page_p.w = w;
			entry->page_p.x = x;
			set_pointer(entry, dst);
		}else if(entry->p){
			table = get_pointer(entry);
		}else{
			if(*free == 0){	return 0; }

			table = construct_pt(next_table);
			*free -= 1;

			entry->p = entry->t = 1;
			set_pointer(entry, table);
		}
	}
	return 1;
}
예제 #7
0
파일: table.cpp 프로젝트: bitelchux/tarotaf
bool Table::on_button_press_event(GdkEventButton* event)
{
	if(event->button==1)
	{
		int c=on_deck();
		if(c!=-1)
		{
			std::cout<<"Drag begin"<<std::endl;
			
			//Evaluate the grab point on the card
			int x,y;
			get_pointer(x,y);					
			card_list[c]->drag_x=x-(2+get_width()/40*c);
			card_list[c]->drag_y=y-(get_height()-card_list[c]->card_f->scaled->get_height());
			card_list[c]->drag_xb=x;		
			card_list[c]->drag_yb=y;

			card_list[c]->moving=true; 
			
			//Copy of the dragged card
			card_dragged = new card;
			card_dragged = card_list[c];
			
			card_drag=true;
			
			//No card is being pointed
			for (card_it=card_list.begin();card_it!=card_list.end();card_it++)
			{			
				(*card_it)->pointed=false;
			}
		
		}
	}
	
	return true;	
}
예제 #8
0
파일: mmalloc.c 프로젝트: IlVerz/rockbox
void* MikMod_realloc(void *data, size_t size)
{
	return realloc(data, size);
	
#if 0
	if (data)
	{
#if defined __MACH__
		void *d = realloc(data, size);
		if (d)
		{
			return d;
		}
		return 0;
#elif (defined _WIN32 || defined _WIN64) && !defined(_WIN32_WCE)
		return _aligned_realloc(data, size, ALIGN_STRIDE);
#else
		unsigned char *newPtr = (unsigned char *)realloc(get_pointer(data), size + ALIGN_STRIDE + sizeof(void*));
		return align_pointer(newPtr, ALIGN_STRIDE);
#endif
	}
	return MikMod_malloc(size);
#endif
}
예제 #9
0
파일: item.cpp 프로젝트: ronniwe/Varios
bool CItem::Unequip()
{
	if (!m_pOwner || GetCell() < INVENTORY_MAX_NUM)
	{
		// ITEM_OWNER_INVALID_PTR_BUG
		sys_err("%s %u m_pOwner %p, GetCell %d", 
				GetName(), GetID(), get_pointer(m_pOwner), GetCell());
		// END_OF_ITEM_OWNER_INVALID_PTR_BUG
		return false;
	}

	if (this != m_pOwner->GetWear(GetCell() - INVENTORY_MAX_NUM))
	{
		sys_err("m_pOwner->GetWear() != this");
		return false;
	}

	//½Å±Ô ¸» ¾ÆÀÌÅÛ Á¦°Å½Ã ó¸®
	if (IsRideItem())
		ClearMountAttributeAndAffect();

	if (IsDragonSoul())
	{
		DSManager::instance().DeactivateDragonSoul(this);
	}
	else
	{
		ModifyPoints(false);
	}

	StopUniqueExpireEvent();

	if (-1 != GetProto()->cLimitTimerBasedOnWearIndex)
		StopTimerBasedOnWearExpireEvent();

	// ACCESSORY_REFINE
	StopAccessorySocketExpireEvent();
	// END_OF_ACCESSORY_REFINE


	m_pOwner->BuffOnAttr_RemoveBuffsFromItem(this);

	m_pOwner->SetWear(GetCell() - INVENTORY_MAX_NUM, NULL);

	DWORD dwImmuneFlag = 0;

	for (int i = 0; i < WEAR_MAX_NUM; i++)
	{
		LPITEM pItem = m_pOwner->GetWear(i);
		if (pItem)
		{
			SET_BIT(dwImmuneFlag, m_pOwner->GetWear(i)->GetImmuneFlag());
		}
	}

	m_pOwner->SetImmuneFlag(dwImmuneFlag);

	m_pOwner->ComputeBattlePoints();

	m_pOwner->UpdatePacket();

	m_pOwner = NULL;
	m_wCell = 0;
	m_bEquipped	= false;

	return true;
}
예제 #10
0
 static void set_bits(pointer &n, std::size_t c)
 {
    BOOST_INTRUSIVE_INVARIANT_ASSERT(c <= Mask);
    n = pointer(std::size_t(get_pointer(n)) | c);
 }
예제 #11
0
파일: that_ptr.hpp 프로젝트: 3Jade/Sprawl
 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
 static inline pointee * do_get_pointer(T & x, void const *) 
 {
     return get_pointer(x); 
 }
예제 #12
0
SdfAttributeSpecHandle
SdfAttributeSpec::_New(
    const SdfRelationshipSpecHandle& owner,
    const SdfPath& path,
    const std::string& name,
    const SdfValueTypeName& typeName,
    SdfVariability variability,
    bool custom)
{
    if (not owner) {
        TF_CODING_ERROR("NULL owner");
        return TfNullPtr;
    }
    if (not typeName) {
        TF_CODING_ERROR("Cannot create attribute spec <%s> with invalid type",
                        owner->GetPath().AppendTarget(path).
                            AppendProperty(TfToken(name)).GetText());
	return TfNullPtr;
    }

    SdfChangeBlock block;

    // Determine the path of the relationship target
    SdfPath absPath = path.MakeAbsolutePath(owner->GetPath().GetPrimPath());
    SdfPath targetPath = owner->GetPath().AppendTarget(absPath);

    // Check to make sure that the name is valid
    if (not Sdf_ChildrenUtils<Sdf_AttributeChildPolicy>::IsValidName(name)) {
        TF_CODING_ERROR(
            "Cannot create attribute on %s with invalid name: %s",
            targetPath.GetText(), name.c_str());
        return TfNullPtr;
    }

    // Create the relationship target if it doesn't already exist. Note
    // that this does not automatically get added to the relationship's
    // target path list.
    SdfSpecHandle targetSpec = owner->_FindOrCreateTargetSpec(path);

    // AttributeSpecs are considered initially to have only required fields 
    // only if they are not custom.
    bool hasOnlyRequiredFields = (not custom);

    // Create the relational attribute spec
    SdfPath attrPath = targetPath.AppendRelationalAttribute(TfToken(name));
    if (not Sdf_ChildrenUtils<Sdf_AttributeChildPolicy>::CreateSpec(
            owner->GetLayer(), attrPath, SdfSpecTypeAttribute, 
            hasOnlyRequiredFields)) {
        return TfNullPtr;
    }

    SdfAttributeSpecHandle spec =
        owner->GetLayer()->GetAttributeAtPath(attrPath);
    
    // Avoid expensive dormancy checks in the case of binary-backed data.
    SdfAttributeSpec *specPtr = get_pointer(spec);
    if (TF_VERIFY(specPtr)) {
        specPtr->SetField(SdfFieldKeys->Custom, custom);
        specPtr->SetField(SdfFieldKeys->TypeName, typeName.GetAsToken());
        specPtr->SetField(SdfFieldKeys->Variability, variability);
    }

    return spec;
}
예제 #13
0
 static inline PyTypeObject* get_class_object(Ptr const& x)
 {
     return get_class_object_impl(get_pointer(x));
 }
예제 #14
0
 void release()
 {
     weak = const_cast<void*>(static_cast<void const*>(
         get_pointer(p)));
     release_ownership(p);
 }
예제 #15
0
파일: mem_fn.hpp 프로젝트: AlexMioMio/boost
 template<class U> R const & call(U & u, void const *) const
 {
     return (get_pointer(u)->*f_);
 }
예제 #16
0
 T * get_handle(tagged_node_handle const & handle) const
 {
     return get_pointer(handle);
 }
예제 #17
0
void CParty::SendMessage(LPCHARACTER ch, BYTE bMsg, DWORD dwArg1, DWORD dwArg2)
{
	if (ch->GetParty() != this)
	{
		sys_err("%s is not member of this party %p", ch->GetName(), this);
		return;
	}

	switch (bMsg)
	{
		case PM_ATTACK:
			break;

		case PM_RETURN:
			{
				TMemberMap::iterator it = m_memberMap.begin();

				while (it != m_memberMap.end())
				{
					TMember & rMember = it->second;
					++it;

					LPCHARACTER pkChr;

					if ((pkChr = rMember.pCharacter) && ch != pkChr)
					{
						DWORD x = dwArg1 + number(-500, 500);
						DWORD y = dwArg2 + number(-500, 500);

						pkChr->SetVictim(NULL);
						pkChr->SetRotationToXY(x, y);

						if (pkChr->Goto(x, y))
						{
							LPCHARACTER victim = pkChr->GetVictim();
							sys_log(0, "%s %p RETURN victim %p", pkChr->GetName(), get_pointer(pkChr), get_pointer(victim));
							pkChr->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0);
						}
					}
				}
			}
			break;

		case PM_ATTACKED_BY:	// 공격 받았음, 리더에게 도움을 요청
			{
				// 리더가 없을 때
				LPCHARACTER pkChrVictim = ch->GetVictim();

				if (!pkChrVictim)
					return;

				TMemberMap::iterator it = m_memberMap.begin();

				while (it != m_memberMap.end())
				{
					TMember & rMember = it->second;
					++it;

					LPCHARACTER pkChr;

					if ((pkChr = rMember.pCharacter) && ch != pkChr)
					{
						if (pkChr->CanBeginFight())
							pkChr->BeginFight(pkChrVictim);
					}
				}
			}
			break;

		case PM_AGGRO_INCREASE:
			{
				LPCHARACTER victim = CHARACTER_MANAGER::instance().Find(dwArg2);

				if (!victim)
					return;

				TMemberMap::iterator it = m_memberMap.begin();

				while (it != m_memberMap.end())
				{
					TMember & rMember = it->second;
					++it;

					LPCHARACTER pkChr;

					if ((pkChr = rMember.pCharacter) && ch != pkChr)
					{
						pkChr->UpdateAggrPoint(victim, DAMAGE_TYPE_SPECIAL, dwArg1);
					}
				}
			}
			break;
	}
}
예제 #18
0
bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes, int & r_iBytesProceed)
{
	const char * c_pData = (const char *) c_pvOrig;

	BYTE	bLastHeader = 0;
	int		iLastPacketLen = 0;
	int		iPacketLen;

	if (!m_pPacketInfo)
	{
		sys_err("No packet info has been binded to");
		return true;
	}

	for (m_iBufferLeft = iBytes; m_iBufferLeft > 0;)
	{
		BYTE bHeader = (BYTE) *(c_pData);
		const char * c_pszName;

		if (bHeader == 0) // 암호화 처리가 있으므로 0번 헤더는 스킵한다.
			iPacketLen = 1;
		else if (!m_pPacketInfo->Get(bHeader, &iPacketLen, &c_pszName))
		{
			sys_err("UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, fd: %d",
					bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, lpDesc->GetSocket());
			//printdata((BYTE *) c_pvOrig, m_iBufferLeft);
			lpDesc->SetPhase(PHASE_CLOSE);
			return true;
		}

		if (m_iBufferLeft < iPacketLen)
			return true;

		if (bHeader)
		{
			if (test_server && bHeader != HEADER_CG_MOVE)
				sys_log(0, "Packet Analyze [Header %d][bufferLeft %d] ", bHeader, m_iBufferLeft);

			m_pPacketInfo->Start();

			int iExtraPacketSize = Analyze(lpDesc, bHeader, c_pData);

			if (iExtraPacketSize < 0)
				return true;

			iPacketLen += iExtraPacketSize;
			lpDesc->Log("%s %d", c_pszName, iPacketLen);
			m_pPacketInfo->End();
		}

		// TRAFFIC_PROFILER
		if (g_bTrafficProfileOn)
			TrafficProfiler::instance().Report(TrafficProfiler::IODIR_INPUT, bHeader, iPacketLen);
		// END_OF_TRAFFIC_PROFILER

		if (bHeader == HEADER_CG_PONG)
			sys_log(0, "PONG! %u %u", m_pPacketInfo->IsSequence(bHeader), *(BYTE *) (c_pData + iPacketLen - sizeof(BYTE)));

		if (m_pPacketInfo->IsSequence(bHeader))
		{
			BYTE bSeq = lpDesc->GetSequence();
			BYTE bSeqReceived = *(BYTE *) (c_pData + iPacketLen - sizeof(BYTE));

			if (bSeq != bSeqReceived)
			{
				sys_err("SEQUENCE %x mismatch 0x%x != 0x%x header %u", get_pointer(lpDesc), bSeq, bSeqReceived, bHeader);

				LPCHARACTER	ch = lpDesc->GetCharacter();

				char buf[1024];
				int	offset, len;

				offset = snprintf(buf, sizeof(buf), "SEQUENCE_LOG [%s]-------------\n", ch ? ch->GetName() : "UNKNOWN");

				if (offset < 0 || offset >= (int) sizeof(buf))
					offset = sizeof(buf) - 1;

				for (size_t i = 0; i < lpDesc->m_seq_vector.size(); ++i)
				{
					len = snprintf(buf + offset, sizeof(buf) - offset, "\t[%03d : 0x%x]\n",
							lpDesc->m_seq_vector[i].hdr,
							lpDesc->m_seq_vector[i].seq);

					if (len < 0 || len >= (int) sizeof(buf) - offset)
						offset += (sizeof(buf) - offset) - 1;
					else
						offset += len;
				}

				snprintf(buf + offset, sizeof(buf) - offset, "\t[%03d : 0x%x]\n", bHeader, bSeq);
				sys_err("%s", buf);

				lpDesc->SetPhase(PHASE_CLOSE);
				return true;
			}
			else
			{
				lpDesc->push_seq(bHeader, bSeq);
				lpDesc->SetNextSequence();
				//sys_err("SEQUENCE %x match %u next %u header %u", lpDesc, bSeq, lpDesc->GetSequence(), bHeader);
			}
		}

		c_pData	+= iPacketLen;
		m_iBufferLeft -= iPacketLen;
		r_iBytesProceed += iPacketLen;

		iLastPacketLen = iPacketLen;
		bLastHeader	= bHeader;

		if (GetType() != lpDesc->GetInputProcessor()->GetType())
			return false;
	}

	return true;
}
예제 #19
0
 static typename result<Env,PtrActor,MemFunPtrActor>::type
 eval(const Env& env, PtrActor& ptrActor, MemFunPtrActor& memFunPtrActor)
 {
     return (get_pointer(ptrActor.eval(env))->*memFunPtrActor.eval(env))();
 }
예제 #20
0
파일: table.cpp 프로젝트: bitelchux/tarotaf
void Table::draw_table()
{
	//If drag and drag inital save not done
	if(!drag_save && card_drag)
	{
		//Draw a proper version		
		draw_background(); 
		draw_deck();
		//Save it in a pixmap
		back_drag->draw_drawable(get_style()->get_black_gc(),back,
							0,0,0,0,-1,-1);
		drag_save=true;
		get_window()->draw_drawable(get_style()->get_black_gc(),back_drag,
								0,0,0,0,-1,-1); 
	}
	if(!card_drag)
	{
		//Draw the differents parts of the table
		draw_background();
		draw_deck();	

		//Display the entire pixmap
		get_window()->draw_drawable(get_style()->get_black_gc(),back,
								0,0,0,0,-1,-1); 
	}
	//Low processor - Inspired by Belooted
	else
	{
		int x;int y;
		get_pointer(x,y);
		int ax,ay,aw,ah,bw,bh,bx,by;
		
		if(abs(x-card_dragged->drag_xb)>card_dragged->card_f->scaled->get_width() || abs(y-card_dragged->drag_yb)>card_dragged->card_f->scaled->get_height())
		{
			std::cout<<"X Grand"<<std::endl;
			ax=card_dragged->drag_xb-card_dragged->drag_x;
			ay=card_dragged->drag_yb-card_dragged->drag_y;
			aw=card_dragged->card_f->scaled->get_width();
			ah=card_dragged->card_f->scaled->get_height();
			bx=by=bw=bh=0;
		}
		else
		{
			if(x>card_dragged->drag_xb)
			{
				if(y>card_dragged->drag_yb)
				{
					ax=card_dragged->drag_xb-card_dragged->drag_x;
					ay = card_dragged->drag_yb-card_dragged->drag_y;
					bx=ax;by=ay;
					ah= card_dragged->card_f->scaled->get_height();
					aw=x-card_dragged->drag_xb;	
					bh=y-card_dragged->drag_yb;
					bw=card_dragged->card_f->scaled->get_width();	
					
				}
				else
				{
					ax=card_dragged->drag_xb-card_dragged->drag_x;
					ay=card_dragged->drag_yb-card_dragged->drag_y;
					
					bx=ax;
					by=y+(card_dragged->card_f->scaled->get_height()-card_dragged->drag_y);
					
					ah= card_dragged->card_f->scaled->get_height();					
					aw=x-card_dragged->drag_xb;
					
					bh=card_dragged->drag_yb-y;
					bw=card_dragged->card_f->scaled->get_width();				
					
				}							
			}
			else
			{
				if(y>card_dragged->drag_yb)
				{
					ax=card_dragged->drag_xb-card_dragged->drag_x;
					ay=card_dragged->drag_yb-card_dragged->drag_y;
					
					bx=x-card_dragged->drag_x+card_dragged->card_f->scaled->get_width();
					by=ay;
					
					ah=y-card_dragged->drag_yb;
					aw=card_dragged->card_f->scaled->get_width();
					
					bh=card_dragged->card_f->scaled->get_height();
					bw=card_dragged->drag_xb-card_dragged->drag_x;	
					
				}
				else
				{
					ax=card_dragged->drag_xb-card_dragged->drag_x;
					ay=y+(card_dragged->card_f->scaled->get_height()-card_dragged->drag_y);
					
					bx=x+(card_dragged->card_f->scaled->get_width()-card_dragged->drag_x);
					by=card_dragged->drag_yb-card_dragged->drag_y;
					
					ah=card_dragged->drag_yb-y;
					aw=card_dragged->card_f->scaled->get_width();
					
					bh=card_dragged->card_f->scaled->get_height();
					bw=card_dragged->drag_xb-x;				
					
				}			
			}
			
			
		}		
		
		//Load the saved inital table
		get_window()->draw_drawable(get_style()->get_black_gc(),back_drag,
								ax,ay,
								ax,ay,
								aw,ah);
		
		get_window()->draw_drawable(get_style()->get_black_gc(),back_drag,
								bx,by,
								bx,by,
								bw,bh);
		
		card_dragged->drag_xb=x;
		card_dragged->drag_yb=y;
		
		
		
		//Draw the dragged card
		get_window()->draw_pixbuf(get_style()->get_black_gc(),card_dragged->card_f->scaled,
						0, 0,x-card_dragged->drag_x,y-card_dragged->drag_y,-1,-1,Gdk::RGB_DITHER_NONE, 0, 0);	
		
		
	}	

}
예제 #21
0
파일: questpc.cpp 프로젝트: Rarder44/Server
	void PC::AddTimer(const string & name, LPEVENT pEvent)
	{
		RemoveTimer(name);
		m_TimerMap.insert(make_pair(name, pEvent));
		sys_log(0, "QUEST add timer %p %d", get_pointer(pEvent), m_TimerMap.size());
	}
예제 #22
0
 T& get() { return *get_pointer(); }
예제 #23
0
 const T& get() const { return *get_pointer(); }
예제 #24
0
파일: Util.cpp 프로젝트: Jontte/Sarona
	virtual scene::IAnimatedMesh * createMesh (io::IReadFile *file)
	{
		video::IVideoDriver * driver = m_device->getVideoDriver();
		intrusive_ptr<video::IImage> img =
			intrusive_ptr<video::IImage>(driver->createImageFromFile(file), false);
		if(!img)
		{
			return false;
		}

		core::dimension2d<u32> size = img->getDimension();


		intrusive_ptr<scene::SMesh> mesh(new scene::SMesh, false);
		intrusive_ptr<scene::IAnimatedMesh> animmesh(new scene::SAnimatedMesh(get_pointer(mesh)), false);

		const u32 meshbuffer_size = driver -> getMaximalPrimitiveCount();

		int rows_per_buffer = meshbuffer_size / ((size.Width-1) * 2);

		int trianglecount = 2 * (size.Width-1) * (size.Height-1);
		int buffercount = trianglecount/meshbuffer_size+1;

		for(int i = 0; i < buffercount; i++)
		{
			int starty = rows_per_buffer*i;
			int endy = rows_per_buffer*(i+1);

			if(endy > size.Height)endy = size.Height;

			// create new buffer...
			scene::SMeshBuffer * buffer = new scene::SMeshBuffer;
			mesh->addMeshBuffer(buffer);
			buffer->drop(); // now owned by mesh

			buffer->Vertices.set_used((1 + endy - starty) * size.Width);
			int idx = 0;
			for(int y = starty; y < endy; y++)
			{
				for(int x = 0; x < size.Width; x++)
				{
					 // center the model around -0.5 -> 0.5 on every axis
					float pz = get_height(get_pointer(img), x, y);
					float px = float(x)/(size.Width-1);
					float py = float(y)/(size.Height-1);

					video::S3DVertex& v = buffer->Vertices[idx++];
					v.Pos.set(-0.5+px, -0.5+py, -0.5+pz);

					v.Normal.set(0,0,1);

					if(x < size.Width-1)
						v.Normal.X -= size.Width/(get_height(get_pointer(img), x+1, y)-get_height(get_pointer(img), x, y));
					if(x > 0)
						v.Normal.X += size.Width/(get_height(get_pointer(img), x-1, y)-get_height(get_pointer(img), x, y));

					if(y < size.Height-1)
						v.Normal.Y -= size.Height/(get_height(get_pointer(img), x, y+1)-get_height(get_pointer(img), x, y));
					if(y > 0)
						v.Normal.Y += size.Height/(get_height(get_pointer(img), x, y-1)-get_height(get_pointer(img), x, y));

					v.Normal.normalize();

					v.Color.set(255,255,255,255);
					v.TCoords.set(px, py);
				}
			}

			idx = 0;
			buffer->Indices.set_used(6 * (size.Width-1) * (endy-starty));
			for(int y = starty; y < endy; y++)
			{
				for(int x = 0; x < size.Width-1; x++)
				{
					int n = (y-starty) * size.Width + x;
					buffer->Indices[idx++] = n;
					buffer->Indices[idx++] = n + size.Height + 1;
					buffer->Indices[idx++] = n + size.Height;

					buffer->Indices[idx++] = n + size.Height + 1;
					buffer->Indices[idx++] = n;
					buffer->Indices[idx++] = n + 1;
				}
			}

			buffer -> recalculateBoundingBox();
		}
		// make animmesh outlive this scope
		animmesh->grab();
		return get_pointer(animmesh);
	}
예제 #25
0
 wrap_base const* get_back_reference_aux2(T const& x, mpl::true_)
 {
     return get_back_reference_aux1(get_pointer(x));
 }
void OXMLi_ListenerState_Table::startElement (OXMLi_StartElementRequest * rqst)
{
	if (nameMatches(rqst->pName, NS_W_KEY, "tbl"))
	{
		OXML_Element_Table* pTable = new OXML_Element_Table("");
		m_tableStack.push(pTable);
		OXML_SharedElement table(pTable);
		rqst->stck->push(table);
		rqst->handled = true;
		pTable->setCurrentRowNumber(-1);
		pTable->setCurrentColNumber(-1);
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "tr"))
	{
		if(m_tableStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Table* table = m_tableStack.top();
		OXML_Element_Row* pRow = new OXML_Element_Row("", table);
		m_rowStack.push(pRow);
		OXML_SharedElement row(pRow);
		rqst->stck->push(row);
		rqst->handled = true;
		table->incrementCurrentRowNumber();
		table->setCurrentColNumber(0);
		pRow->setRowNumber(table->getCurrentRowNumber());
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "tc"))
	{
		if(m_tableStack.empty() || m_rowStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Table* table = m_tableStack.top();				
		OXML_Element_Row* row = m_rowStack.top();				
		OXML_Element_Cell* pCell = new OXML_Element_Cell("", table, row, 
								table->getCurrentColNumber(), table->getCurrentColNumber()+1, //left right
								table->getCurrentRowNumber(), table->getCurrentRowNumber()+1); //top,bottom
		m_cellStack.push(pCell);
		OXML_SharedElement cell(pCell);
		rqst->stck->push(cell);
		rqst->handled = true;
		table->incrementCurrentColNumber();
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "gridSpan"))
	{
		if(m_tableStack.empty() || m_cellStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Table* table = m_tableStack.top();				
		const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);
		if(val)
		{
			int span = atoi(val);
			int left = table->getCurrentColNumber()-1;
			int right = left + span;
			//change current cell's right index
			OXML_Element_Cell* cell = m_cellStack.top();
			cell->setRight(right);
			//update column index of current table			
			table->setCurrentColNumber(right);
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "vMerge"))
	{
		if(m_cellStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Cell* cell = m_cellStack.top();				
		cell->setVerticalMergeStart(false); //default to continue if the attribute is missing
		const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);
		if(val && !strcmp(val, "restart")) 
		{
			cell->setVerticalMergeStart(true);
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "hMerge"))
	{
		if(m_cellStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Cell* cell = m_cellStack.top();				
		cell->setHorizontalMergeStart(false); //default to continue if the attribute is missing
		const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);
		if(val && !strcmp(val, "restart")) 
		{
			cell->setHorizontalMergeStart(true);
		}
		rqst->handled = true;
	}

	//Table Properties
	else if(nameMatches(rqst->pName, NS_W_KEY, "gridCol") && 
			contextMatches(rqst->context->back(), NS_W_KEY, "tblGrid"))
	{
		if(m_tableStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Table* table = m_tableStack.top();				
		const gchar* w = attrMatches(NS_W_KEY, "w", rqst->ppAtts);
		if(w) 
		{
			//append this width to table-column-props property
			const gchar* tableColumnProps = NULL;
			UT_Error ret = table->getProperty("table-column-props", tableColumnProps);
			if((ret != UT_OK) || !tableColumnProps)
				tableColumnProps = "";				
			std::string cols(tableColumnProps);
			cols += _TwipsToPoints(w);
			cols += "pt/";
			ret = table->setProperty("table-column-props", cols);
			if(ret != UT_OK)
			{	
				UT_DEBUGMSG(("FRT:OpenXML importer can't set table-column-props:%s\n", cols.c_str()));
			}
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "trHeight") && 
			contextMatches(rqst->context->back(), NS_W_KEY, "trPr"))
	{
		if(m_tableStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Table* table = m_tableStack.top();				
		const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);
		if(val) 
		{
			const gchar* tableRowHeights = NULL;
			UT_Error ret = table->getProperty("table-row-heights", tableRowHeights);
			if((ret != UT_OK) || !tableRowHeights)
				tableRowHeights = "";				
			std::string rowHeights(tableRowHeights);
			rowHeights += _TwipsToPoints(val);
			rowHeights += "pt/";
			ret = table->setProperty("table-row-heights", rowHeights);
			if(ret != UT_OK)
			{
				UT_DEBUGMSG(("FRT:OpenXML importer can't set table-row-heights:%s\n", rowHeights.c_str()));
			}
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "left") ||
			nameMatches(rqst->pName, NS_W_KEY, "right") ||
			nameMatches(rqst->pName, NS_W_KEY, "top") ||
			nameMatches(rqst->pName, NS_W_KEY, "bottom"))
	{
		rqst->handled = true;
		const gchar* color = attrMatches(NS_W_KEY, "color", rqst->ppAtts);
		const gchar* sz = attrMatches(NS_W_KEY, "sz", rqst->ppAtts);
		const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);

		UT_Error ret = UT_OK;

		std::string borderName(rqst->pName);
		borderName = borderName.substr(strlen(NS_W_KEY)+1);
		if(!borderName.compare("bottom"))
			borderName = "bot";

		std::string borderStyle = borderName + "-style";
		std::string borderColor = borderName + "-color";
		std::string borderThickness = borderName + "-thickness";

		OXML_Element* element = NULL;

		if(rqst->context->empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		if(contextMatches(rqst->context->back(), NS_W_KEY, "tcBorders"))
			element = m_cellStack.empty() ? NULL : m_cellStack.top();
		else if(contextMatches(rqst->context->back(), NS_W_KEY, "tblBorders"))
			element = m_tableStack.empty() ? NULL : m_tableStack.top();

		if(!element)
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		if(color && strcmp(color, "auto")) 
		{
			ret = element->setProperty(borderColor, color);
			if(ret != UT_OK)
			{
				UT_DEBUGMSG(("FRT:OpenXML importer can't set %s:%s\n", borderColor.c_str(), color));
			}
		}
		if(sz) 
		{
			std::string szVal(_EighthPointsToPoints(sz));
			szVal += "pt";
			ret = element->setProperty(borderThickness, szVal);
			if(ret != UT_OK)
			{
				UT_DEBUGMSG(("FRT:OpenXML importer can't set %s:%s\n", borderThickness.c_str(), color));
			}
		}

		std::string styleValue = "1"; //single line border by default
		if(val)
		{
			if(!strcmp(val, "dashed"))
				styleValue = "0"; 
		}

		ret = element->setProperty(borderStyle, styleValue);
		if(ret != UT_OK)
		{
			UT_DEBUGMSG(("FRT:OpenXML importer can't set %s:0\n", borderStyle.c_str()));
		}
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "shd"))
	{
		const gchar* fill = attrMatches(NS_W_KEY, "fill", rqst->ppAtts);

		UT_Error ret = UT_OK;
		OXML_Element* element = NULL;

		if(rqst->context->empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		if(contextMatches(rqst->context->back(), NS_W_KEY, "tcPr"))
			element = m_cellStack.empty() ? NULL : m_cellStack.top();
		else if(contextMatches(rqst->context->back(), NS_W_KEY, "tblPr"))
			element = m_tableStack.empty() ? NULL : m_tableStack.top();

		if(!element)
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		if(fill && strcmp(fill, "auto")) 
		{
			ret = element->setProperty("background-color", fill);
			if(ret != UT_OK)
			{
				UT_DEBUGMSG(("FRT:OpenXML importer can't set background-color:%s\n", fill));	
			}
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "tblStyle"))
	{
		if(m_tableStack.empty())
		{
			rqst->handled = false;
			rqst->valid = false;
			return;
		}

		OXML_Element_Table* table = m_tableStack.top();				
		const gchar* val = attrMatches(NS_W_KEY, "val", rqst->ppAtts);
		if(val && table) 
		{
			std::string styleName(val);
			OXML_Document* doc = OXML_Document::getInstance();
			if(doc)
				table->applyStyle(doc->getStyleById(styleName));
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "tblPr"))
	{
		if(m_tableStack.empty())
		{
			//we must be in tblStyle in styles, so let's push the table instance to m_tableStack
			OXML_Element_Table* tbl = static_cast<OXML_Element_Table*>(get_pointer(rqst->stck->top()));
			m_tableStack.push(tbl);
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "trPr"))
	{
		if(m_rowStack.empty())
		{
			//we must be in styles, so let's push the row instance to m_rowStack
			OXML_Element_Row* row = static_cast<OXML_Element_Row*>(get_pointer(rqst->stck->top()));
			m_rowStack.push(row);
		}
		rqst->handled = true;
	}
	else if(nameMatches(rqst->pName, NS_W_KEY, "tcPr"))
	{
		if(m_cellStack.empty())
		{
			//we must be in styles, so let's push the cell instance to m_cellStack
			OXML_Element_Cell* cell = static_cast<OXML_Element_Cell*>(get_pointer(rqst->stck->top()));
			m_cellStack.push(cell);
		}
		rqst->handled = true;
	}
	//TODO: more coming here
}
예제 #27
0
static int init_geom(client_t *c, strut_t *s)
{
    Atom win_type, state;
    int screen_x = DisplayWidth(dpy, screen);
    int screen_y = DisplayHeight(dpy, screen);
    int wmax = screen_x - s->left - s->right;
    int hmax = screen_y - s->top - s->bottom;
    int mouse_x, mouse_y;

    /* We decide the geometry for these types of windows, so we can just
     * ignore everything and return right away. If c->zoomed is set, that
     * means we've already set things up, but otherwise, we do it here. */
    if (c->zoomed)
        return 1;
    if (get_atoms(c->win, net_wm_state, XA_ATOM, 0, &state, 1, NULL) &&
            state == net_wm_state_fs) {
        c->geom.x = 0;
        c->geom.y = 0;
        c->geom.w = screen_x;
        c->geom.h = screen_y;
        return 1;
    }

    /* Here, we merely set the values; they're in the same place regardless
     * of whether the user or the program specified them. We'll distinguish
     * between the two cases later, if we need to. */
    if (c->size.flags & (USSize|PSize)) {
        if (c->size.width > 0) c->geom.w = c->size.width;
        if (c->size.height > 0) c->geom.h = c->size.height;
    }
    if (c->size.flags & (USPosition|PPosition)) {
        if (c->size.x > 0) c->geom.x = c->size.x;
        if (c->size.y > 0) c->geom.y = c->size.y;
    }

    /* Several types of windows can put themselves wherever they want, but we
     * need to read the size hints to get that position before returning. */
    if (get_atoms(c->win, net_wm_wintype, XA_ATOM, 0, &win_type, 1, NULL) &&
            CAN_PLACE_SELF(win_type))
        return 1;

    /* At this point, maybe nothing was set, or something went horribly wrong
     * and the values are garbage. So, make a guess, based on the pointer. */
    if (c->geom.x <= 0 && c->geom.y <= 0) {
        get_pointer(&mouse_x, &mouse_y);
        recalc_map(c, c->geom, mouse_x, mouse_y, mouse_x, mouse_y, s);
    }

    /* In any case, if we got this far, we need to do a further sanity check
     * and make sure that the window isn't overlapping any struts -- except
     * for transients, because they might be a panel-type client popping up a
     * notification window over themselves. */
    if (!c->trans) {
        if (c->geom.x + c->geom.w > screen_x - s->right)
            c->geom.x = screen_x - s->right - c->geom.w;
        if (c->geom.y + c->geom.h > screen_y - s->bottom)
            c->geom.y = screen_y - s->bottom - c->geom.h;
        if (c->geom.x < s->left || c->geom.w > wmax)
            c->geom.x = s->left;
        if (c->geom.y < s->top || c->geom.h > hmax)
            c->geom.y = s->top;
    }

    /* Finally, we decide if we were ultimately satisfied with the position
     * given, or if we had to make something up, so that the caller can
     * consider using some other method. */
    return c->trans || c->size.flags & USPosition;
}
예제 #28
0
파일: perfroll.cpp 프로젝트: Stazed/seq32
bool
perfroll::on_key_press_event(GdkEventKey* a_p0)
{
    if (a_p0->keyval == m_mainperf->m_key_pointer)         /* Move to mouse position */
    {
        int x = 0;
        int y = 0;

        long a_tick = 0;

        get_pointer(x, y);
        if(x < 0)
            x = 0;
        snap_x(&x);
        convert_x(x, &a_tick);

        if(m_mainperf->is_jack_running())
        {
            m_mainperf->set_reposition();
            m_mainperf->set_starting_tick(a_tick);
            m_mainperf->position_jack(true, a_tick);
        }
        else
        {
            m_mainperf->set_reposition();
            m_mainperf->set_starting_tick(a_tick);
        }

        return true;
    }

    bool ret = false;

    if ( m_mainperf->is_active( m_drop_sequence))
    {
        if ( a_p0->type == GDK_KEY_PRESS )
        {
            if ( a_p0->keyval ==  GDK_Delete || a_p0->keyval == GDK_BackSpace )
            {
                m_mainperf->push_trigger_undo(m_drop_sequence);
                m_mainperf->get_sequence( m_drop_sequence )->del_selected_trigger();

                ret = true;
            }

            if ( a_p0->state & GDK_CONTROL_MASK )
            {
                /* cut */
                if ( a_p0->keyval == GDK_x || a_p0->keyval == GDK_X )
                {
                    m_mainperf->push_trigger_undo(m_drop_sequence);
                    m_mainperf->get_sequence( m_drop_sequence )->cut_selected_trigger();
                    ret = true;
                }
                /* copy */
                if ( a_p0->keyval == GDK_c || a_p0->keyval == GDK_C )
                {
                    m_mainperf->get_sequence( m_drop_sequence )->copy_selected_trigger();
                    ret = true;
                }

                /* paste */
                if ( a_p0->keyval == GDK_v || a_p0->keyval == GDK_V )
                {
                    m_mainperf->push_trigger_undo(m_drop_sequence);
                    m_mainperf->get_sequence( m_drop_sequence )->paste_trigger();
                    ret = true;
                }
            }
        }
    }

    if ( ret == true )
    {
        fill_background_pixmap();
        queue_draw();
        return true;
    }
    else
        return false;
}
예제 #29
0
static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque,
                      Error **errp)
{
    get_pointer(obj, v, opaque, print_drive, name, errp);
}
예제 #30
0
void OXML_Element_Table::applyStyle(OXML_SharedStyle style)
{
	inheritProperties(get_pointer(style));
}