Example #1
0
static Status load_sys_cursor(const PIVFS& vfs, const VfsPath& pathname, int hx, int hy, sys_cursor* cursor)
{
#if !ALLOW_SYS_CURSOR
	UNUSED2(vfs);
	UNUSED2(pathname);
	UNUSED2(hx);
	UNUSED2(hy);
	UNUSED2(cursor);

	return ERR::FAIL;
#else
	shared_ptr<u8> file; size_t fileSize;
	RETURN_STATUS_IF_ERR(vfs->LoadFile(pathname, file, fileSize));

	Tex t;
	RETURN_STATUS_IF_ERR(t.decode(file, fileSize));

	// convert to required BGRA format.
	const size_t flags = (t.m_Flags | TEX_BGR) & ~TEX_DXT;
	RETURN_STATUS_IF_ERR(t.transform_to(flags));
	void* bgra_img = t.get_data();
	if(!bgra_img)
		WARN_RETURN(ERR::FAIL);

	RETURN_STATUS_IF_ERR(sys_cursor_create((int)t.m_Width, (int)t.m_Height, bgra_img, hx, hy, cursor));
	return INFO::OK;
#endif
}
Example #2
0
File: io.cpp Project: 2asoft/0ad
Status WaitUntilComplete(aiocb& cb, size_t queueDepth)
{
#if CONFIG2_FILE_ENABLE_AIO
	if(queueDepth > 1)
	{
		aiocb* const cbs = &cb;
		timespec* const timeout = 0;	// infinite
SUSPEND_AGAIN:
		errno = 0;
		const int ret = aio_suspend(&cbs, 1, timeout);
		if(ret != 0)
		{
			if(errno == EINTR) // interrupted by signal
				goto SUSPEND_AGAIN;
			WARN_RETURN(StatusFromErrno());
		}

		const int err = aio_error(&cb);
		ENSURE(err != EINPROGRESS);	// else aio_return is undefined
		ssize_t bytesTransferred = aio_return(&cb);
		if(bytesTransferred == -1)	// transfer failed
		{
			errno = err;
			WARN_RETURN(StatusFromErrno());
		}
		cb.aio_nbytes = (size_t)bytesTransferred;
	}
#else
	UNUSED2(cb);
	UNUSED2(queueDepth);
#endif

	return INFO::OK;
}
Example #3
0
	void draw(int x, int y) const
	{
#if CONFIG2_GLES
		UNUSED2(x); UNUSED2(y);
#warning TODO: implement cursors for GLES
#else
		(void)ogl_tex_bind(ht);
		glEnable(GL_TEXTURE_2D);
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
		glDisable(GL_DEPTH_TEST);
		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

		glBegin(GL_QUADS);
		glTexCoord2i(1, 0); glVertex2i( x-hotspotx+w, y+hotspoty   );
		glTexCoord2i(0, 0); glVertex2i( x-hotspotx,   y+hotspoty   );
		glTexCoord2i(0, 1); glVertex2i( x-hotspotx,   y+hotspoty-h );
		glTexCoord2i(1, 1); glVertex2i( x-hotspotx+w, y+hotspoty-h );
		glEnd();

		glDisable(GL_BLEND);
		glEnable(GL_DEPTH_TEST);
#endif
	}
Example #4
0
File: unix.cpp Project: Marlinc/0ad
// note: do not return ERR_NOT_IMPLEMENTED or similar because that
// would result in WARN_ERRs.
Status sys_cursor_create(size_t w, size_t h, void* bgra_img, size_t hx, size_t hy, sys_cursor* cursor)
{
	UNUSED2(w);
	UNUSED2(h);
	UNUSED2(hx);
	UNUSED2(hy);
	UNUSED2(bgra_img);

	*cursor = 0;
	return INFO::OK;
}
Example #5
0
File: unix.cpp Project: Marlinc/0ad
Status sys_StatusDescription(int err, wchar_t* buf, size_t max_chars)
{
	UNUSED2(err);
	UNUSED2(buf);
	UNUSED2(max_chars);

	// don't need to do anything: lib/errors.cpp already queries
	// libc's strerror(). if we ever end up needing translation of
	// e.g. Qt or X errors, that'd go here.
	return ERR::FAIL;
}
Example #6
0
void CMiniMap::FireWorldClickEvent(int button, int clicks)
{
	float x, z;
	GetMouseWorldCoordinates(x, z);

	CScriptValRooted coords;
	g_ScriptingHost.GetScriptInterface().Eval("({})", coords);
	g_ScriptingHost.GetScriptInterface().SetProperty(coords.get(), "x", x, false);
	g_ScriptingHost.GetScriptInterface().SetProperty(coords.get(), "z", z, false);
	ScriptEvent("worldclick", coords);

	UNUSED2(button);
	UNUSED2(clicks);
}
Example #7
0
    virtual void PlaySoundGroup(std::wstring name, entity_id_t source)
    {
#if CONFIG2_AUDIO
        // Make sure the sound group is loaded
        CSoundGroup* group;
        if (m_SoundGroups.find(name) == m_SoundGroups.end())
        {
            group = new CSoundGroup();
            if (!group->LoadSoundGroup(L"audio/" + name))
            {
                LOGERROR(L"Failed to load sound group '%ls'", name.c_str());
                delete group;
                group = NULL;
            }
            // Cache the sound group (or the null, if it failed)
            m_SoundGroups[name] = group;
        }
        else
        {
            group = m_SoundGroups[name];
        }

        // Failed to load group -> do nothing
        if (!group)
            return;

        // Only play the sound if the entity is visible
        CmpPtr<ICmpRangeManager> cmpRangeManager(GetSimContext(), SYSTEM_ENTITY);
        ICmpRangeManager::ELosVisibility vis = cmpRangeManager->GetLosVisibility(source, GetSimContext().GetCurrentDisplayedPlayer());

        if (vis == ICmpRangeManager::VIS_VISIBLE)
        {
            // Find the source's position, if possible
            // (TODO: we should do something more sensible if there's no position available)
            CVector3D sourcePos(0, 0, 0);
            if (source != INVALID_ENTITY)
            {
                CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), source);
                if (cmpPosition && cmpPosition->IsInWorld())
                    sourcePos = CVector3D(cmpPosition->GetPosition());
            }

            group->PlayNext(sourcePos);
        }
#else // !CONFIG2_AUDIO
        UNUSED2(name);
        UNUSED2(source);
#endif // !CONFIG2_AUDIO
    }
Example #8
0
	virtual void SetShadingColour(fixed r, fixed g, fixed b, fixed a)
	{
		m_R = r;
		m_G = g;
		m_B = b;
		UNUSED2(a); // TODO: why is this even an argument?
	}
Example #9
0
File: CGUI.cpp Project: 2asoft/0ad
void CGUI::Destroy()
{
	// We can use the map to delete all
	//  now we don't want to cancel all if one Destroy fails
	for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects)
	{
		try
		{
			p.second->Destroy();
		}
		catch (PSERROR_GUI& e)
		{
			UNUSED2(e);
			debug_warn(L"CGUI::Destroy error");
			// TODO Gee: Handle
		}

		delete p.second;
	}
	m_pAllObjects.clear();

	for (const std::pair<CStr, CGUISprite*>& p : m_Sprites)
		delete p.second;
	m_Sprites.clear();
	m_Icons.clear();
}
Example #10
0
void CGUI::Destroy()
{
	// We can use the map to delete all
	//  now we don't want to cancel all if one Destroy fails
	for (map_pObjects::iterator it = m_pAllObjects.begin(); it != m_pAllObjects.end(); ++it)
	{
		try
		{
			it->second->Destroy();
		}
		catch (PSERROR_GUI& e)
		{
			UNUSED2(e);
			debug_warn(L"CGUI::Destroy error");
			// TODO Gee: Handle
		}
		
		delete it->second;
	}

	// Clear all
	m_pAllObjects.clear();
	for(std::map<CStr, CGUISprite*>::iterator it = m_Sprites.begin(); it != m_Sprites.end(); ++it)
		delete it->second;
	m_Sprites.clear();
	m_Icons.clear();
}
Example #11
0
void CStdDeserializer::Get(const char* name, u8* data, size_t len)
{
#if DEBUG_SERIALIZER_ANNOTATE
	std::string strName;
	char c = m_Stream.get();
	ENSURE(c == '<');
	while (1)
	{
		c = m_Stream.get();
		if (c == '>')
			break;
		else
			strName += c;
	}
	ENSURE(strName == name);
#else
	UNUSED2(name);
#endif
	m_Stream.read((char*)data, (std::streamsize)len);
	if (!m_Stream.good())
	{
		// hit eof before len, or other errors
		// NOTE: older libc++ versions incorrectly set eofbit on the last char; test gcount as a workaround
		// see https://llvm.org/bugs/show_bug.cgi?id=9335
		if (m_Stream.bad() || m_Stream.fail() || (m_Stream.eof() && m_Stream.gcount() != (std::streamsize)len))
			throw PSERROR_Deserialize_ReadFailed();
	}
}
Example #12
0
File: io.cpp Project: 2asoft/0ad
Status Issue(aiocb& cb, size_t queueDepth)
{
#if CONFIG2_FILE_ENABLE_AIO
	if(queueDepth > 1)
	{
		const int ret = (cb.aio_lio_opcode == LIO_WRITE)? aio_write(&cb): aio_read(&cb);
		if(ret != 0)
			WARN_RETURN(StatusFromErrno());
	}
	else
#else
	UNUSED2(queueDepth);
#endif
	{
		ENSURE(lseek(cb.aio_fildes, cb.aio_offset, SEEK_SET) == cb.aio_offset);

		void* buf = (void*)cb.aio_buf;	// cast from volatile void*
		const ssize_t bytesTransferred = (cb.aio_lio_opcode == LIO_WRITE)? write(cb.aio_fildes, buf, cb.aio_nbytes) : read(cb.aio_fildes, buf, cb.aio_nbytes);
		if(bytesTransferred < 0)
			WARN_RETURN(StatusFromErrno());

		cb.aio_nbytes = (size_t)bytesTransferred;
	}

	return INFO::OK;
}
Example #13
0
char *hhfi_get_filespec(
        void *db,
        int64_t hash
) {
    UNUSED2(db, hash);
    return NULL;
}
Example #14
0
/*static*/ OsPath Paths::RootData(const OsPath& argv0)
{

#ifdef INSTALLED_DATADIR
	UNUSED2(argv0);
	return OsPath(STRINGIZE(INSTALLED_DATADIR))/"";
#else

# if OS_MACOSX
	if (osx_IsAppBundleValid())
	{
		debug_printf(L"Valid app bundle detected\n");

		std::string resourcesPath = osx_GetBundleResourcesPath();
		// Ensure we have a valid resources path
		ENSURE(!resourcesPath.empty());

		return OsPath(resourcesPath)/"data"/"";
	}
# endif // OS_MACOSX

	return Root(argv0)/"data"/"";

#endif // INSTALLED_DATADIR
}
Example #15
0
JSBool JSI_IGUIObject::getComputedSize(JSContext* cx, uintN argc, jsval* vp)
{
	UNUSED2(argc);

	IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
	if (!e)
		return JS_FALSE;

	e->UpdateCachedSize();
	CRect size = e->m_CachedActualSize;

	JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
	try
	{
		g_ScriptingHost.SetObjectProperty_Double(obj, "left", size.left);
		g_ScriptingHost.SetObjectProperty_Double(obj, "right", size.right);
		g_ScriptingHost.SetObjectProperty_Double(obj, "top", size.top);
		g_ScriptingHost.SetObjectProperty_Double(obj, "bottom", size.bottom);
	}
	catch (PSERROR_Scripting_ConversionFailed)
	{
		debug_warn(L"Error creating size object!");
		return JS_FALSE;
	}

	JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
	return JS_TRUE;
}
Example #16
0
JSBool JSI_GUISize::toString(JSContext* cx, uint argc, jsval* vp)
{
    UNUSED2(argc);

    CStr buffer;

    try
    {
        ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface;
        double val, valr;
#define SIDE(side) \
		pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), #side, val); \
		pScriptInterface->GetProperty(JS_THIS_VALUE(cx, vp), "r"#side, valr); \
		buffer += ToPercentString(val, valr);
        SIDE(left);
        buffer += " ";
        SIDE(top);
        buffer += " ";
        SIDE(right);
        buffer += " ";
        SIDE(bottom);
#undef SIDE
    }
    catch (PSERROR_Scripting_ConversionFailed&)
    {
        JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "<Error converting value to numbers>")));
        return JS_TRUE;
    }

    JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buffer.c_str())));
    return JS_TRUE;
}
Example #17
0
bool JSound::SetPitch(JSContext* cx, uintN UNUSED(argc), jsval* argv)
{
#if CONFIG2_AUDIO
	if (! m_SndItem)
		return false;

	float pitch;
	if (! ToPrimitive<float>(cx, argv[0], pitch))
		return false;
	
	m_SndItem->SetPitch(pitch);
#else // !CONFIG2_AUDIO
	UNUSED2(cx);
	UNUSED2(argv);
#endif // CONFIG2_AUDIO
	return true;
}
Example #18
0
static bool VerifyPages(void* mem, size_t size, size_t pageSize, size_t node)
{
	WUTIL_FUNC(pQueryWorkingSetEx, BOOL, (HANDLE, PVOID, DWORD));
	WUTIL_IMPORT_KERNEL32(QueryWorkingSetEx, pQueryWorkingSetEx);
	if(!pQueryWorkingSetEx)
		return true;	// can't do anything

#if WINVER >= 0x600
	size_t largePageSize = os_cpu_LargePageSize();
	ENSURE(largePageSize != 0); // this value is needed for later

	// retrieve attributes of all pages constituting mem
	const size_t numPages = (size + pageSize-1) / pageSize;
	PSAPI_WORKING_SET_EX_INFORMATION* wsi = new PSAPI_WORKING_SET_EX_INFORMATION[numPages];
	for(size_t i = 0; i < numPages; i++)
		wsi[i].VirtualAddress = (u8*)mem + i*pageSize;
	pQueryWorkingSetEx(GetCurrentProcess(), wsi, DWORD(sizeof(PSAPI_WORKING_SET_EX_INFORMATION)*numPages));

	// ensure each is valid and allocated on the correct node
	for(size_t i = 0; i < numPages; i++)
	{
		const PSAPI_WORKING_SET_EX_BLOCK& attributes = wsi[i].VirtualAttributes;
		if(!attributes.Valid)
			return false;
		if((attributes.LargePage != 0) != (pageSize == largePageSize))
		{
			debug_printf("NUMA: is not a large page\n");
			return false;
		}
		if(attributes.Node != node)
		{
			debug_printf("NUMA: allocated from remote node\n");
			return false;
		}
	}

	delete[] wsi;
#else
	UNUSED2(mem);
	UNUSED2(size);
	UNUSED2(pageSize);
	UNUSED2(node);
#endif

	return true;
}
Example #19
0
	JSBool Construct(JSContext* cx, uintN argc, jsval* vp)
	{
		UNUSED2(argc);

		JSObject *newObj = JS_NewObject(cx, &Class, NULL, NULL);
		JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(newObj));
		return JS_TRUE;
	}
///////////////////////////////////////////////////////////////////////
///  Function: XosWebRtcClientConnection::
///
///    Author: $author$
///      Date: 4/1/2012
///////////////////////////////////////////////////////////////////////
void XosWebRtcClientConnection::OnHangingGetConnect(talk_base::AsyncSocket* socket) {
  char buffer[1024];
  talk_base::sprintfn(buffer, sizeof(buffer),
           "GET /wait?peer_id=%i HTTP/1.0\r\n\r\n", my_id_);
  int len = strlen(buffer);
  int sent = socket->Send(buffer, len);
  ASSERT(sent == len);
  UNUSED2(sent, len);
}
Example #21
0
JSound::JSound(const VfsPath& pathname)
{
#if CONFIG2_AUDIO
	if ( g_SoundManager )
		m_SndItem = g_SoundManager->LoadItem(pathname);
#else // !CONFIG2_AUDIO
	UNUSED2(pathname);
#endif // !CONFIG2_AUDIO
}
Example #22
0
const Structures* GetStructures()
{
	static ModuleInitState initState;
	Status ret = ModuleInit(&initState, InitStructures);
	// (callers have to check if member pointers are nonzero anyway, so
	// we always return a valid pointer to simplify most use cases.)
	UNUSED2(ret);
	return &structures;
}
Example #23
0
void CSoundManager::PlayAsAmbient(const VfsPath& itemPath, bool looping)
{
	if (m_Enabled)
	{
		UNUSED2(looping);
		ISoundItem* aSnd = LoadItem(itemPath);
		if (aSnd != NULL)
			SetAmbientItem(aSnd);
	}
}
Example #24
0
    void Put(const char* name, const u8* UNUSED(data), size_t len)
    {
#if DEBUG_SERIALIZER_ANNOTATE
        m_Length += 2;	// '<' and '>'
        m_Length += strlen(name);
#else
        UNUSED2(name);
#endif
        m_Length += len;
    }
Example #25
0
static BOOL CALLBACK FindAppWindowByPid(HWND hWnd, LPARAM UNUSED(lParam))
{
	DWORD pid;
	DWORD tid = GetWindowThreadProcessId(hWnd, &pid);
	UNUSED2(tid);

	if(pid == GetCurrentProcessId())
		hAppWindow = hWnd;

	return TRUE;	// keep calling
}
Example #26
0
bool JSound::SetPosition(JSContext* cx, uintN argc, jsval* argv)
{
#if CONFIG2_AUDIO
	if (! m_SndItem)
		return false;
	
	ENSURE(argc >= 1); // FIXME
	
	CVector3D pos;
	// absolute world coords
	if (!ToPrimitive<CVector3D>(cx, argv[0], pos))
		return false;

	m_SndItem->SetLocation(pos);
#else // !CONFIG2_AUDIO
	UNUSED2(cx);
	UNUSED2(argc);
	UNUSED2(argv);
#endif // !CONFIG2_AUDIO
	return true;
}
Example #27
0
JSBool DumpHeaps(JSContext* cx, uintN argc, jsval* vp)
{
	UNUSED2(cx);
	UNUSED2(argc);

#if MOZJS_DEBUG_ABI
	static int i = 0;

	if (ScriptingHost::IsInitialised())
		DumpHeap("gui", i, g_ScriptingHost.GetContext());
	if (g_Game)
		DumpHeap("sim", i, g_Game->GetSimulation2()->GetScriptInterface().GetContext());

	++i;
#else
	debug_warn(L"DumpHeaps only available in DEBUG mode");
#endif

	JS_SET_RVAL(cx, vp, JSVAL_VOID);
	return JS_TRUE;
}
Example #28
0
JSBool JSI_IGUIObject::blur(JSContext* cx, uintN argc, jsval* vp)
{
	UNUSED2(argc);

	IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
	if (!e)
		return JS_FALSE;

	e->GetGUI()->SetFocusedObject(NULL);

	JS_SET_RVAL(cx, vp, JSVAL_VOID);
	return JS_TRUE;
}
Example #29
0
bool JSound::Fade(JSContext* cx, uintN UNUSED(argc), jsval* argv)
{
#if CONFIG2_AUDIO
	if (! m_SndItem)
		return false;
	
//	ENSURE(argc >= 3); // FIXME
	float initial_gain, final_gain;
	float length;
	if (! (ToPrimitive<float>(cx, argv[0], initial_gain)
		   && ToPrimitive<float>(cx, argv[1], final_gain)
		   && ToPrimitive<float>(cx, argv[2], length)))
		return false;
	
	m_SndItem->SetGain(initial_gain);
	m_SndItem->FadeToIn(final_gain, length);
#else // !CONFIG2_AUDIO
	UNUSED2(cx);
	UNUSED2(argv);
#endif // !CONFIG2_AUDIO
	return true;
}
Example #30
0
    void Put(const char* name, const u8* data, size_t len)
    {
#if DEBUG_SERIALIZER_ANNOTATE
        std::string tag = "<";
        tag.append(name);
        tag.append(">");
        memcpy(m_Buffer, tag.c_str(), tag.length());
        m_Buffer += tag.length();
#else
        UNUSED2(name);
#endif
        memcpy(m_Buffer, data, len);
        m_Buffer += len;
    }