Exemple #1
0
void CEntity::UpdateMovement(Ogre::Real ElapsedTime)
{
	//Also update walk/idle animation?
	if( IsMoving() ){
		Ogre::Real LenghtLeftToGo = (GetDestination() - GetPosition()).length();
		Ogre::Vector3 Movement = GetMovement();
		Ogre::Vector3 CorrectedMovement = ( Movement * ElapsedTime );

		//Set the right angle for the entity
		mNode->lookAt( GetDestination(), Ogre::Node::TS_WORLD );

		if( CorrectedMovement.length() < LenghtLeftToGo ){ //Not at destination yet, just move
			mNode->translate( CorrectedMovement );
		}else{ //Arrived at destination
			mNode->setPosition( GetDestination() );
			ReachedDestination();
			//TODO: If there is a next destination then go there with the frametime left of this movement.
			//(Loop till all frametime is used for movement)
			//Example: if there are 3 destinations left, and the first 2 will be reached
			//in 2 seconds.
			//If the user has a slow computer that updates the frame every 2,5 seconds,
			//then it should first use x seconds to reach destination one, then check
			//for how many seconds left, and use those to go to the next node and so on.
		}
	}
}
Exemple #2
0
nsresult
nsPrintJobVMSCmdPS::FinishSubmission()
{
    NS_PRECONDITION(GetDestHandle(), "No destination file handle");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");

    /* Close the temporary file handle */
    fclose(GetDestHandle());
    SetDestHandle(nsnull);

    /* construct the print command */
    nsCAutoString printFileName;
    nsresult rv = mTempFile->GetNativePath(printFileName);
    if (NS_SUCCEEDED(rv)) {
        nsCAutoString cmd(GetDestination());
        cmd += " "; cmd += printFileName; cmd += ".";

        /* Set up the environment. */
        if (PR_SUCCESS != EnvLock())
            return NS_ERROR_OUT_OF_MEMORY;
        if (!mPrinterName.IsEmpty())
            EnvSetPrinter(mPrinterName);

        /* Run the print command */
        int presult = system(cmd.get());

        /* Clean up */
        EnvClear();
        mTempFile->Remove(PR_FALSE);

        rv = (!WIFEXITED(presult) || (EXIT_SUCCESS != WEXITSTATUS(presult)))
            ? NS_ERROR_GFX_PRINTER_CMD_FAILURE : NS_OK;
    }
    return rv;
}
Exemple #3
0
nsresult
nsPrintJobCUPS::FinishSubmission()
{
    NS_ENSURE_TRUE(mCups.IsInitialized(), NS_ERROR_NOT_INITIALIZED);
    NS_PRECONDITION(GetDestHandle(), "No destination file handle");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");

    fclose(GetDestHandle());
    SetDestHandle(nsnull);

    nsCStringArray printer(3);
    printer.ParseString(mPrinterName.get(),"/");

    cups_dest_t *dests, *dest;
    int num_dests = (mCups.mCupsGetDests)(&dests);
    
    if (printer.Count() == 1) {
        dest = (mCups.mCupsGetDest)(printer.CStringAt(0)->get(), NULL, num_dests, dests);
    } else {
        dest = (mCups.mCupsGetDest)(printer.CStringAt(0)->get(), 
                                    printer.CStringAt(1)->get(), num_dests, dests);
    }

    // Setting result just to get rid of compilation warning
    int result=0;
    if (dest != NULL) {
        if (!mNumCopies.IsEmpty())
            dest->num_options = (mCups.mCupsAddOption)("copies",
                                                       mNumCopies.get(),
                                                       dest->num_options,
                                                       &dest->options);
        const char *title = mJobTitle.IsVoid() ?
            "Untitled Document" : mJobTitle.get();
        result = (mCups.mCupsPrintFile)(printer.CStringAt(0)->get(),
                                            GetDestination().get(), title, 
                                            dest->num_options, dest->options);
    }
    (mCups.mCupsFreeDests)(num_dests, dests);
    unlink(GetDestination().get());

    // cupsPrintFile() result codes below 0x0300 indicate success.
    // Individual success codes are defined in the cups headers, but
    // we're not including those.
    if (dest == NULL)
        return NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND;
    else
        return (result < 0x0300) ? NS_OK : NS_ERROR_GFX_PRINTER_CMD_FAILURE;
}
void LoadDatabase(QueryResult * pResult)
{
    pResult = SD2Database.PQuery(
        "SELECT flag, data0, data1, CatId, C.name, destid "
        "FROM sd2p_npc_tele_category C, sd2p_npc_tele_association A "
        "WHERE C.id = CatId ORDER BY C.name, CatId");
    VCategorie.clear();

    if (pResult)
    {
        outstring_log("SD2P: Chargement \"sd2p_npc_tele_category\" et \"sd2p_npc_tele_association\"...");
        barGoLink Bar(pResult->GetRowCount());

        uint32 CatId  = 0;
        uint32 NbDest = 0;
        bool IsValidCat = true;
        bool FirstTime  = true;

        do
        {
            Bar.step();
            Field * pFields = pResult->Fetch();

            if (!GetDestination(pFields[5].GetUInt32()))
            {
                outstring_log("SD2P >> Destination introuvable (DestID: %u).", pFields[5].GetUInt32());
                continue;
            }

            if (!IsValidCat && CatId == pFields[3].GetUInt32() && !FirstTime)
                continue;

            IsValidCat = true;
            FirstTime = false;

            if (!IsValidData(pFields[3].GetUInt32(), (Flag_t)pFields[0].GetUInt8(),
                             pFields[1].GetUInt64(), pFields[2].GetUInt32()))
            {
                IsValidCat = false;
                CatId = pFields[3].GetUInt32();
                continue;
            }

            if (CatId != pFields[3].GetUInt32())
            {
                CatId = pFields[3].GetUInt32();
                Categorie Cat (CatId, pFields[4].GetCppString(), (Flag_t)pFields[0].GetUInt8(),
                               pFields[1].GetUInt64(), pFields[2].GetUInt32());
                VCategorie.push_back(Cat);
            }

            VCategorie.back().AddDest(pFields[5].GetUInt32());
            ++NbDest;
        } while (pResult->NextRow());

        delete pResult;
        outstring_log("");
        outstring_log(">> %u npc_teleport charge(s).", NbDest);
    } else outstring_log("WARNING >> 0 npc_teleport charge.");
}
Exemple #5
0
/**
 * Launch the print command using popen(), then copy the print job data
 * to the pipe. See nsIPrintJobPS.h and nsPrintJobPS.h for details.
 */
nsresult
nsPrintJobPipePS::StartSubmission(FILE **aHandle)
{
    NS_PRECONDITION(aHandle, "aHandle is NULL");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");
    NS_PRECONDITION(!GetDestHandle(), "Already have a destination handle");

    if (PR_SUCCESS != EnvLock())
        return NS_ERROR_OUT_OF_MEMORY;  // Couldn't allocate the object?
    if (!mPrinterName.IsEmpty())
        EnvSetPrinter(mPrinterName);

    FILE *destPipe = popen(GetDestination().get(), "w");
    EnvClear();
    if (!destPipe)
        return NS_ERROR_GFX_PRINTER_CMD_FAILURE;
    SetDestHandle(destPipe);
    *aHandle = destPipe;
    return NS_OK;
}
Exemple #6
0
nsresult
nsPrintJobPipePS::FinishSubmission()
{
    NS_PRECONDITION(GetDestHandle(), "No destination file handle");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");

    int presult = pclose(GetDestHandle());
    SetDestHandle(nsnull);
    if (!WIFEXITED(presult) || (EXIT_SUCCESS != WEXITSTATUS(presult)))
        return NS_ERROR_GFX_PRINTER_CMD_FAILURE;
    return NS_OK;
}
const Destination * DEFIT::GetAllowedDestination(Player * const pPlayer) const
{
    for (VDestObjectTele_t::const_iterator It = m_VDestObjectTele.begin(); It != m_VDestObjectTele.end(); ++It)
    {
        if (It->IsValid(*this, pPlayer))
        {
            const Destination * pDest = GetDestination(It->m_DestId);
            if (pDest) return pDest;
            outstring_log("SD2P >> [Object Tele] Destination invalide (Id: %u).",It->m_DestId);
        }
    }
    return NULL;
}
void ImageMultiplexer::AddImage(const std::string& strComputer, ImageTopic topic, const cv::Mat& image)
{
  unsigned int width;
  unsigned int height;
  GetImageDimensions(width, height);

  cv::Mat  resizedImage = ResizeImage(image, width, height);

  cv::Point point1;
  cv::Point point2;
  if (GetDestination(strComputer, topic, point1, point2))
  {
    // TODO: Copy resizedImage to m_image from point1 to point2
  }
}
void FlyOrLandMovementGenerator::Initialize(Unit& unit)
{
    if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
        return;

    unit.StopMoving();

    float x, y, z;
    GetDestination(x, y, z);
    unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
    Movement::MoveSplineInit init(unit);
    init.SetFly();
    init.MoveTo(x, y, z, false);
    init.Launch();
}
Exemple #10
0
// We use an rdf attribute to mark if this is a container or not.
// Note that we still have to do string comparisons as a fallback
// because stuff like the personal toolbar and bookmarks check whether
// a URL is a container, and we have no attribute in that case.
PRBool
nsHTTPIndex::isWellknownContainerURI(nsIRDFResource *r)
{
  nsCOMPtr<nsIRDFNode> node;
  GetTarget(r, kNC_IsContainer, PR_TRUE, getter_AddRefs(node));
  if (node) {
    PRBool isContainerFlag;
    if (NS_SUCCEEDED(node->EqualsNode(kTrueLiteral, &isContainerFlag)))
      return isContainerFlag;
  }

  nsXPIDLCString uri;
  GetDestination(r, uri);
  return uri.get() && !strncmp(uri, kFTPProtocol, sizeof(kFTPProtocol) - 1) &&
         (uri.Last() == '/');
}
Exemple #11
0
/**
 * Create the temporary file for the print job and return a file handle
 * to the caller.
 * See nsIPrintJobPS.h and nsPrintJobPS.h for details.
 */
nsresult
nsPrintJobVMSCmdPS::StartSubmission(FILE **aHandle)
{
    NS_PRECONDITION(aHandle, "aHandle is NULL");
    NS_PRECONDITION(!GetDestination().IsEmpty(), "No destination");
    NS_PRECONDITION(!GetDestHandle(), "Already have a destination handle");

    /* Create the final output file */
    FILE *printHandle = nsnull;
    nsresult rv = mTempFactory.CreateTempFile(
            getter_AddRefs(mTempFile), &printHandle, "w+");
    if (NS_SUCCEEDED(rv)) {
        SetDestHandle(printHandle);
        *aHandle = printHandle;
    }
    return rv;
}
void FlyOrLandMovementGenerator::Initialize(Unit& unit)
{
    if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
        return;

    if (!unit.IsStopped())
        unit.StopMoving();

    float x, y, z;
    GetDestination(x, y, z);
    unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
    Movement::MoveSplineInit init(unit);
    init.SetFly();
    init.SetAnimation((m_liftOff ? Movement::FlyToGround : Movement::ToGround));
    init.MoveTo(x, y, z, false);
    init.Launch();
}
Exemple #13
0
/**
 * Create the final output file and copy the temporary files there.
 * See nsIPrintJobPS.h and nsPrintJobPS.h for details.
 */
nsresult
nsPrintJobFilePS::StartSubmission(FILE **aHandle)
{
    NS_PRECONDITION(aHandle, "aHandle is NULL");
    NS_PRECONDITION(!mDestination.IsEmpty(), "No destination");
    NS_PRECONDITION(!mDestHandle, "Already have a destination handle");

    nsCOMPtr<nsILocalFile> destFile;
    nsresult rv = NS_NewNativeLocalFile(GetDestination(),
            PR_FALSE, getter_AddRefs(destFile));
    if (NS_SUCCEEDED(rv))
        rv = destFile->OpenANSIFileDesc("w", &mDestHandle);
    NS_ENSURE_SUCCESS(rv, NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE);
    NS_POSTCONDITION(mDestHandle,
            "OpenANSIFileDesc succeeded but no file handle");
    *aHandle = mDestHandle;
    return rv;
}
// We use an rdf attribute to mark if this is a container or not.
// Note that we still have to do string comparisons as a fallback
// because stuff like the personal toolbar and bookmarks check whether
// a URL is a container, and we have no attribute in that case.
PRBool
nsHTTPIndex::isWellknownContainerURI(nsIRDFResource *r)
{
  nsCOMPtr<nsIRDFNode> node;
  GetTarget(r, kNC_IsContainer, PR_TRUE, getter_AddRefs(node));

  PRBool isContainerFlag = PR_FALSE;

  if (node && NS_SUCCEEDED(node->EqualsNode(kTrueLiteral, &isContainerFlag))) {
    return isContainerFlag;
  } else {
    nsXPIDLCString uri;
    
    // For gopher, we need to follow the URL attribute to get the
    // real destination
    GetDestination(r,uri);

    if ((uri.get()) && (!strncmp(uri, kFTPProtocol, sizeof(kFTPProtocol) - 1))) {
      if (uri.Last() == '/') {
        isContainerFlag = PR_TRUE;
      }
    }

    // A gopher url is of the form:
    // gopher://example.com/xFileNameToGet
    // where x is a single character representing the type of file
    // 1 is a directory, and 7 is a search.
    // Searches will cause a dialog to be popped up (asking the user what
    // to search for), and so even though searches return a directory as a
    // result, don't treat it as a directory here.

    // The isContainerFlag test above will correctly handle this when a
    // search url is passed in as the baseuri
    if ((uri.get()) &&
        (!strncmp(uri,kGopherProtocol, sizeof(kGopherProtocol)-1))) {
      char* pos = PL_strchr(uri+sizeof(kGopherProtocol)-1, '/');
      if (!pos || pos[1] == '\0' || pos[1] == '1')
        isContainerFlag = PR_TRUE;
    }
  }
  return isContainerFlag;
}
Exemple #15
0
/*********************************************************************************
 Function		: ReplaceArguments

 Description	: Try to replace uses of a register.

 Parameters		: uReplaceCodeCount				- Count of instructions to replace
												the register within.
				  puReplaceCode					- Instruction to replace the register
												in.
				  bOldRegIsTemp					- If TRUE the register to be replaced
												is a temporary otherwise it is a
												primary attribute.
				  uOldRegNum					- Number of the register to be replaced.
				  eNewRegType					- Type of the replacement register.
				  uNewRegNum					- Number of the replacement register.
				  bDoReplace					- If TRUE replace the register otherwise
												just check if replacement is possible.

 Return			: TRUE if replacing the register is possible.
*********************************************************************************/
static IMG_BOOL ReplaceArguments(IMG_UINT32				uReplaceCodeCount,
								 IMG_PUINT32			puReplaceCode,
								 IMG_BOOL				bOldRegIsTemp,
								 IMG_UINT32				uOldRegNum,
								 REGISTER_TYPE			eNewRegType,
								 IMG_UINT32				uNewRegNum,
								 IMG_BOOL				bDoReplace)
{
	IMG_UINT32	uInstIdx;
	IMG_BOOL	bNewRegOverwritten = IMG_FALSE;

	for (uInstIdx = 0; uInstIdx < uReplaceCodeCount; uInstIdx++)
	{
		IMG_UINT32	uInst0, uInst1;
		IMG_UINT32	uOp;
		IMG_UINT32	uSrcsUsedMask;
		IMG_UINT32	uDestMask;
		IMG_BOOL	bShortPredicate;
		IMG_UINT32	uSrc;

		uInst0 = puReplaceCode[uInstIdx * 2 + 0];
		uInst1 = puReplaceCode[uInstIdx * 2 + 1];

		uOp = (uInst1 & ~EURASIA_USE1_OP_CLRMSK) >> EURASIA_USE1_OP_SHIFT;

		/*
			Check which source arguments are used by the instruction.
		*/
		uDestMask = 0xF;
		switch (uOp)
		{
			case EURASIA_USE1_OP_PCKUNPCK:
			{
				uSrcsUsedMask = 6;
				bShortPredicate = IMG_FALSE;

				/*
					Get the destination mask.
				*/
				uDestMask = (uInst1 & ~EURASIA_USE1_PCK_DMASK_CLRMSK) >> EURASIA_USE1_PCK_DMASK_SHIFT;
				break;
			}
			case EURASIA_USE1_OP_SOP2:
			{
				uSrcsUsedMask = 6;
				bShortPredicate = IMG_TRUE;
				break;
			}
			case EURASIA_USE1_OP_SOPWM:
			{
				IMG_UINT32	uWriteMask;

				uSrcsUsedMask = 6;

				/*
					Convert the destination mask to BGRA order.
				*/
				uWriteMask = (uInst1 & ~EURASIA_USE1_SOP2WM_WRITEMASK_CLRMSK) >> EURASIA_USE1_SOP2WM_WRITEMASK_SHIFT;
				uDestMask = 0;
				if (uWriteMask & EURASIA_USE1_SOP2WM_WRITEMASK_B) uDestMask |= 1;
				if (uWriteMask & EURASIA_USE1_SOP2WM_WRITEMASK_G) uDestMask |= 2;
				if (uWriteMask & EURASIA_USE1_SOP2WM_WRITEMASK_R) uDestMask |= 4;
				if (uWriteMask & EURASIA_USE1_SOP2WM_WRITEMASK_A) uDestMask |= 8;

				bShortPredicate = IMG_TRUE;
				break;
			}
			case EURASIA_USE1_OP_FPMA:
			case EURASIA_USE1_OP_SOP3:
			{
				uSrcsUsedMask = 7;
				bShortPredicate = IMG_TRUE;
				break;
			}
			case EURASIA_USE1_OP_MOVC:
			{
				IMG_UINT32	uTestType;

				uTestType = (uInst1 & ~EURASIA_USE1_MOVC_TSTDTYPE_CLRMSK) >> EURASIA_USE1_MOVC_TSTDTYPE_SHIFT;
				if (uTestType == EURASIA_USE1_MOVC_TSTDTYPE_UNCOND)
				{
					uSrcsUsedMask = 2;
				}
				else
				{
					uSrcsUsedMask = 7;
				}
				bShortPredicate = IMG_FALSE;
				break;
			}
			default:
			{
				/*
					Give up if the opcode is unknown since we don't know what sources it uses.
				*/
				return IMG_FALSE;
			}
		}

		for (uSrc = 0; uSrc < 3; uSrc++)
		{
			IMG_UINT32	uSrcBank;
			IMG_UINT32	uSrcBankExt;
			IMG_UINT32	uSrcNum;

			if ((uSrcsUsedMask & (1UL << uSrc)) == 0)
			{
				continue;
			}

			/*
				Extract the bank and register number for this argument.
			*/
			GetSource(uInst0, uInst1, uSrc, &uSrcBankExt, &uSrcBank, &uSrcNum);

			/*
				Compare with the register to be replaced.
			*/
			if (
					(
						(uSrcBank == EURASIA_USE0_S1STDBANK_TEMP && uSrcBankExt == 0 && bOldRegIsTemp) ||
						(uSrcBank == EURASIA_USE0_S1STDBANK_PRIMATTR && uSrcBankExt == 0 && !bOldRegIsTemp)
					) &&
					uSrcNum == uOldRegNum
			   )
			{
				if (bDoReplace)
				{
					/*
						Substitute the replacement register.
					*/
					ReplaceArgument(&puReplaceCode[uInstIdx * 2 + 0],
									&puReplaceCode[uInstIdx * 2 + 1],
									uSrc,
									eNewRegType,
									uNewRegNum);
				}
				else
				{
					/*
						We can't use a secondary attribute in hardware source 0.
					*/
					if (
							eNewRegType == REGISTER_TYPE_SECATTR &&
							uSrc == 0
					   )
					{
						return IMG_FALSE;
					}

					/*
						If the replacement register has been overwritten then we can't do the replacement.
					*/
					if (bNewRegOverwritten)
					{
						return IMG_FALSE;
					}
				}
			}
		}

		{
			REGISTER_TYPE	eDestType;
			IMG_UINT32		uDestNum;
			IMG_UINT32		uEPred;

			/*
				Get the instruction predicate.
			*/
			if (bShortPredicate)
			{
				IMG_UINT32	uSPred;

				uSPred = (uInst1 & ~EURASIA_USE1_SPRED_CLRMSK) >> EURASIA_USE1_SPRED_SHIFT;
				switch (uSPred)
				{
					case EURASIA_USE1_SPRED_ALWAYS: uEPred = EURASIA_USE1_EPRED_ALWAYS; break;
					case EURASIA_USE1_SPRED_P0: uEPred = EURASIA_USE1_EPRED_P0; break;
					case EURASIA_USE1_SPRED_P1: uEPred = EURASIA_USE1_EPRED_P1; break;
					case EURASIA_USE1_SPRED_NOTP0: uEPred = EURASIA_USE1_EPRED_NOTP0; break;
					default: PVR_DBG_BREAK; uEPred = 0; break;
				}
			}
			else
			{
				uEPred = (uInst1 & ~EURASIA_USE1_EPRED_CLRMSK) >> EURASIA_USE1_EPRED_SHIFT;
			}

			/*
				Get the destination register.
			*/
			GetDestination(uInst0, uInst1, &eDestType, &uDestNum);

			/*
				If we are completely overwriting the register to be replaced then we have checked all the
				uses of it. If we are conditionally or partially writing it then we can't do the replacement.
			*/
			if (
					(
						(eDestType == REGISTER_TYPE_TEMP && bOldRegIsTemp) ||
						(eDestType == REGISTER_TYPE_PRIMATTR && !bOldRegIsTemp)
					) &&
					uDestNum == uOldRegNum
			   )
			{
				if (uDestMask != 0xF || uEPred != EURASIA_USE1_EPRED_ALWAYS)
				{
					return IMG_FALSE;
				}
				else
				{
					return IMG_TRUE;
				}
			}

			/*
				Check for overwriting the replacement register.
			*/
			if (
					eDestType == eNewRegType &&
					uDestNum == uNewRegNum
			   )
			{
				bNewRegOverwritten = IMG_TRUE;
			}
		}
	}
NS_IMETHODIMP nsDeviceContextSpecOS2::GetSurfaceForPrinter(gfxASurface **surface)
{
  NS_ASSERTION(mQueue, "Queue can't be NULL here");

  nsRefPtr<gfxASurface> newSurface;

  PRInt16 outputFormat;
  mPrintSettings->GetOutputFormat(&outputFormat);
  // for now always set the output format to PDF, see bug 415522:
  printf("print output format is %d but we are setting it to %d (PDF)\n",
         outputFormat, nsIPrintSettings::kOutputFormatPDF);
  outputFormat = nsIPrintSettings::kOutputFormatPDF;
  mPrintSettings->SetOutputFormat(outputFormat); // save PDF format in settings

  if (outputFormat == nsIPrintSettings::kOutputFormatPDF) {
    nsXPIDLString filename;
    mPrintSettings->GetToFileName(getter_Copies(filename));
    nsresult rv;
    if (filename.IsEmpty()) {
      // print to a file that is visible, like one on the Desktop
      nsCOMPtr<nsIFile> pdfLocation;
      rv = NS_GetSpecialDirectory(NS_OS_DESKTOP_DIR, getter_AddRefs(pdfLocation));
      NS_ENSURE_SUCCESS(rv, rv);

      // construct a print output name using the current time, to make it
      // unique and not overwrite existing files
      char printName[CCHMAXPATH];
      PRExplodedTime time;
      PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &time);
      snprintf(printName, CCHMAXPATH-1, "%s_%04d%02d%02d_%02d%02d%02d.pdf",
               MOZ_APP_DISPLAYNAME, time.tm_year, time.tm_month+1, time.tm_mday,
               time.tm_hour, time.tm_min, time.tm_sec);
      printName[CCHMAXPATH-1] = '\0';

      nsCAutoString printString(printName);
      rv = pdfLocation->AppendNative(printString);
      NS_ENSURE_SUCCESS(rv, rv);
      rv = pdfLocation->GetPath(filename);
      NS_ENSURE_SUCCESS(rv, rv);
    }
#ifdef debug_thebes_print
    printf("nsDeviceContextSpecOS2::GetSurfaceForPrinter(): print to filename=%s\n",
           NS_LossyConvertUTF16toASCII(filename).get());
#endif

    double width, height;
    mPrintSettings->GetEffectivePageSize(&width, &height);
    // convert twips to points
    width  /= TWIPS_PER_POINT_FLOAT;
    height /= TWIPS_PER_POINT_FLOAT;

    nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
    rv = file->InitWithPath(filename);
    if (NS_FAILED(rv))
      return rv;

    nsCOMPtr<nsIFileOutputStream> stream = do_CreateInstance("@mozilla.org/network/file-output-stream;1");
    rv = stream->Init(file, -1, -1, 0);
    if (NS_FAILED(rv))
      return rv;

    newSurface = new(std::nothrow) gfxPDFSurface(stream, gfxSize(width, height));
  } else {
    int numCopies = 0;
    int printerDest = 0;
    char *filename = nsnull;

    GetCopies(numCopies);
    GetDestination(printerDest);
    if (!printerDest) {
      GetPath(&filename);
    }
    mPrintingStarted = PR_TRUE;
    mPrintDC = PrnOpenDC(mQueue, "Mozilla", numCopies, printerDest, filename);

    double width, height;
    mPrintSettings->GetEffectivePageSize(&width, &height);
#ifdef debug_thebes_print
    printf("nsDeviceContextSpecOS2::GetSurfaceForPrinter(): %fx%ftwips, copies=%d\n",
           width, height, numCopies);
#endif

    // we need pixels, so scale from twips to the printer resolution
    // and take into account that CAPS_*_RESOLUTION are in px/m, default
    // to approx. 100dpi
    double hDPI = 3937., vDPI = 3937.;
    LONG value;
    if (DevQueryCaps(mPrintDC, CAPS_HORIZONTAL_RESOLUTION, 1, &value))
      hDPI = value * 0.0254;
    if (DevQueryCaps(mPrintDC, CAPS_VERTICAL_RESOLUTION, 1, &value))
      vDPI = value * 0.0254;
    width = width * hDPI / 1440;
    height = height * vDPI / 1440;
#ifdef debug_thebes_print
    printf("nsDeviceContextSpecOS2::GetSurfaceForPrinter(): %fx%fpx (res=%fx%f)\n"
           "  expected size: %7.2f MiB\n",
           width, height, hDPI, vDPI, width*height*4./1024./1024.);
#endif

    // perhaps restrict to usable area
    // (this or scaling down won't help, we will just get more pages and still crash!)
    if (DevQueryCaps(mPrintDC, CAPS_WIDTH, 1, &value) && width > (double)value)
      width = (double)value;
    if (DevQueryCaps(mPrintDC, CAPS_HEIGHT, 1, &value) && height > (double)value)
      height = (double)value;

#ifdef debug_thebes_print
    printf("nsDeviceContextSpecOS2::GetSurfaceForPrinter(): capped? %fx%fpx (res=%fx%f)\n"
           "  expected size: %7.2f MiB per page\n",
           width, height, hDPI, vDPI, width*height*4./1024./1024.);
#endif

    // Now pass the created DC into the thebes surface for printing.
    // It gets destroyed there.
    newSurface = new(std::nothrow)
      gfxOS2Surface(mPrintDC, gfxIntSize(int(ceil(width)), int(ceil(height))));
  }
  if (!newSurface) {
    *surface = nsnull;
    return NS_ERROR_FAILURE;
  }
  *surface = newSurface;
  NS_ADDREF(*surface);
  return NS_OK;
}
void CVehicleWeaponControlled::Update(SEntityUpdateContext& ctx, int update)
{
	IVehicle *pVehicle = m_vehicleId ? gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId) : NULL; 
  if (!m_vehicleId && GetEntity()->GetParent())
  {
    IEntity *entity = GetEntity();
    
    if (entity)
    {
      IEntity *parent = entity->GetParent();
      if (parent)
      {
				m_vehicleId = parent->GetId();
        pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(parent->GetId());
      }
    }
  }



  if (pVehicle)
  {
		IVehiclePart *pPart = pVehicle->GetWeaponParentPart(GetEntityId());
		if(pPart)
		{
			if(IVehiclePart *pParentPart = pPart->GetParent())
			{
				CRY_ASSERT(pVehicle->GetEntity());

				if(ICharacterInstance *characterInst = pVehicle->GetEntity()->GetCharacter(pParentPart->GetSlot()))
				{
					if(ISkeletonPose* pose = characterInst->GetISkeletonPose())
					{
						IDefaultSkeleton& rIDefaultSkeleton = characterInst->GetIDefaultSkeleton();
						int16 joint = rIDefaultSkeleton.GetJointIDByName(pPart->GetName());
						const QuatT &jQuat = pose->GetAbsJointByID(joint);

						Matrix34 localT(jQuat);
						localT.SetTranslation(jQuat.t/* - Vec3(0.0f, 0.75f, 0.0f)*/);

						Matrix34 vehicleWorldTm = pVehicle->GetEntity()->GetWorldTM();
						Matrix34 mat = vehicleWorldTm * localT;
						Vec3 vehicleSide2 = pPart->GetParent()->GetLocalTM(true, true).GetTranslation();

						CPlayer *pl = this->GetOwnerPlayer();

						Matrix33 mat2;
						if (!m_destination.IsEquivalent(ZERO))
						{
							Vec3 diff = GetDestination() - mat.GetTranslation(); //pPart->GetWorldTM().GetTranslation();
							diff.Normalize();

							Matrix33 loc(mat);
							loc.Invert();

							Vec3 diffLocal = loc.TransformVector(diff);

							Matrix33 desMat;
							desMat.SetRotationVDir(diffLocal, 0.0f);

							Vec3 test = GetEntity()->GetLocalTM().GetColumn0();

							Ang3 testTM(desMat);

							float za = testTM.x - m_Angles.x;
							za = (za < 0.0f) ? -gf_PI : gf_PI;
							za *= 0.05f * ctx.fFrameTime;

							m_Angles.x += za;
							Limit(m_Angles.x, -gf_PI * 0.33f, gf_PI * 0.33f);

							if (testTM.z > m_Angles.z + 0.05f)
							{
								m_Angles.z += gf_PI * factor1 * ctx.fFrameTime;        
							}
							else if (testTM.z < m_Angles.z - 0.05f)
							{
								m_Angles.z -= gf_PI * factor1 * ctx.fFrameTime;        
							}
							else
							{
								m_Angles.z = testTM.z;
							}

							Limit(m_Angles.z, -gf_PI * 0.33f, gf_PI * 0.33f);
							mat2.SetRotationXYZ(m_Angles);
						}
						else
						{
							if (!m_FireBlocked)
							{
								m_Angles.x = m_Angles.x - ctx.fFrameTime * factor2 * m_Angles.x;
								m_Angles.z = m_Angles.z - ctx.fFrameTime * factor2 * m_Angles.z;
							}
							mat2.SetRotationXYZ(m_Angles);
						}

						mat = mat * mat2; 


						GetEntity()->SetWorldTM(mat);


						if (pl)
						{
							Matrix34 worldGunMat = vehicleWorldTm * localT;

							if (!pl->IsDead())
							{

								Vec3 trans = worldGunMat.GetTranslation() - worldGunMat.GetColumn2() * 0.7f;
								worldGunMat.SetTranslation(trans);

								pl->GetEntity()->SetWorldTM(worldGunMat);


								float dot = mat.GetColumn1().dot(worldGunMat.GetColumn0());
								Update3PAnim(pl, 0.5f - dot * 0.5f, ctx.fFrameTime, mat);
							}
							else
							{

								ICharacterInstance* pCharacter = pl->GetEntity()->GetCharacter(0);
								int boneId = pCharacter ? pCharacter->GetIDefaultSkeleton().GetJointIDByName("Spine03") : 7;

								pl->LinkToMountedWeapon(0);
								if (IVehicleSeat* seat = pVehicle->GetSeatForPassenger(pl->GetEntityId()))
								{
									seat->Exit(false, true);
								}

								Matrix33 rot(worldGunMat);
								Vec3 offset(0.0f, 0.0f, 0.70f);
								Vec3 transformedOff = rot.TransformVector(offset);
								Vec3 trans = worldGunMat.GetTranslation();
								trans -= transformedOff;
								worldGunMat.SetTranslation(trans);
								pl->GetEntity()->SetWorldTM(worldGunMat);
								pl->GetEntity()->SetPos(worldGunMat.GetTranslation()); //worldGunMat.GetTranslation());
								pl->RagDollize(true);

								if (boneId > -1)
								{
									IPhysicalEntity *physEnt = pl->GetEntity()->GetPhysics();
									if (physEnt)
									{
										pe_simulation_params simulationParams;
										physEnt->GetParams(&simulationParams);

										pe_params_pos pos;
										pos.pos = GetEntity()->GetPos();
										physEnt->SetParams(&pos);

										pe_action_impulse impulse;
										impulse.ipart = boneId;
										impulse.angImpulse = Vec3(0.0f, 0.0f, 1.0f);
										impulse.impulse = worldGunMat.GetColumn1() * -1.5f * simulationParams.mass;
										physEnt->Action(&impulse);
									}
								}

								StopUse(GetOwnerId());

								SetOwnerId(0);
								StopFire();

								m_FireBlocked = true;
							} // IsDead
						} // pl
					} // pose
				} // characterInst
			} // pParentPart
		} // pPart
	} // pVehicle

  Base::Update(ctx, update);
  RequireUpdate(eIUS_General);
}
Packet*
RadioBearer::CreatePacket (int bytes)
{
  Packet *p = new Packet ();

  p->SetID(Simulator::Init()->GetUID ());
  p->SetTimeStamp(Simulator::Init()->Now ());

  UDPHeader *udp = new UDPHeader (GetClassifierParameters ()->GetSourcePort(),
		                          GetClassifierParameters ()->GetDestinationPort ());
  p->AddUDPHeader(udp);

  IPHeader *ip = new IPHeader (GetClassifierParameters ()->GetSourceID (),
                               GetClassifierParameters ()->GetDestinationID());
  p->AddIPHeader(ip);

  PDCPHeader *pdcp = new PDCPHeader ();
  p->AddPDCPHeader (pdcp);

  RLCHeader *rlc = new RLCHeader ();
  p->AddRLCHeader(rlc);

  PacketTAGs *tags = new PacketTAGs ();
  tags->SetApplicationType(PacketTAGs::APPLICATION_TYPE_INFINITE_BUFFER);
  p->SetPacketTags(tags);

  if (_APP_TRACING_)
    {
	  /*
	   * Trace format:
	   *
	   * TX   APPLICATION_TYPE   BEARER_ID  SIZE   SRC_ID   DST_ID   TIME
	   */
	  UserEquipment* ue = (UserEquipment*) GetApplication ()->GetDestination ();
	   std::cout << "TX";
	   switch (p->GetPacketTags ()->GetApplicationType ())
	     {
	       case Application::APPLICATION_TYPE_VOIP:
	         {
	     	  std::cout << " VOIP";
	     	  break;
	         }
	       case Application::APPLICATION_TYPE_TRACE_BASED:
	         {
	           std::cout << " VIDEO";
	     	  break;
	         }
	       case Application::APPLICATION_TYPE_CBR:
	         {
	     	  std::cout << " CBR";
	     	  break;
	         }
	       case Application::APPLICATION_TYPE_INFINITE_BUFFER:
	         {
	     	  std::cout << " INF_BUF";
	     	  break;
	         }
	       default:
	         {
	     	  std::cout << " UNDEFINED";
	     	  break;
	         }
	     }

	   if (bytes > 1490) bytes = 1490;
	   else bytes = bytes - 13;

       std::cout << " ID " << p->GetID ()
	 		    << " B " << GetRlcEntity ()->GetRlcEntityIndex ()
	 			<< " SIZE " << bytes
	 			<< " SRC " << GetSource ()->GetIDNetworkNode ()
	 			<< " DST " << GetDestination ()->GetIDNetworkNode ()
	 			<< " T " << Simulator::Init()->Now()
	 			<< " " << ue->IsIndoor () << std::endl;
    }

  return p;
}
const Destination * DEFIT::GetDest(const uint32 &DestId) const
{
    return GetDestination(m_VDestObjectTele[DestId].m_DestId);
}
void LoadDatabase(void)
{
    // Verification integrite des donnees de la DB
    QueryResult * pResult = SD2Database.PQuery(
    "  SELECT 0 NumRel, T.Entry Entry"
    "  FROM sd2p_object_tele_relation0 T, sd2p_object_tele_definition D "
    "  WHERE T.Entry = D.Entry "
    "    AND relation_id <> 0 "
    "UNION "
    "  SELECT 1 NumRel, T.Entry Entry"
    "  FROM sd2p_object_tele_relation1 T, sd2p_object_tele_definition D "
    "  WHERE T.Entry = D.Entry "
    "    AND relation_id <> 1 "
    "ORDER BY NumRel, Entry");

    if (pResult)
    {
        outstring_log("½Å±¾¿â£º ERREUR >> %u objects incorrectement configures...", pResult->GetRowCount());
        do
        {
            Field * pFields = pResult->Fetch();
            outstring_log("\tIdObject : %u (Relation invalide : %u)",
                          pFields[0].GetUInt32(), pFields[1].GetUInt8());
        } while (pResult->NextRow());

        delete pResult;
    }

    // Recuperation des donnees de la DB
    pResult = SD2Database.PQuery(
    "  SELECT relation_id, flag, Data0, Data1, T.Entry Entry, DestId "
    "  FROM sd2p_object_tele_definition D, sd2p_object_tele_relation0 T "
    "  WHERE D.Entry = T.Entry "
    "    AND relation_id = 0 "
    "UNION "
    "  SELECT relation_id, flag, Data0, Data1, T.Entry Entry, DestId "
    "  FROM sd2p_object_tele_definition D, sd2p_object_tele_relation1 T "
    "  WHERE D.Entry = T.Entry "
    "    AND relation_id = 1 "
    "ORDER BY relation_id, Entry, flag, Data0 DESC ");
    MDefObject.clear();

    if (pResult)
    {
        outstring_log( "SD2P: Chargement \"sd2p_object_tele_definition\" et \"sd2p_object_tele_relation0\"...");
        barGoLink Bar(pResult->GetRowCount());

        uint32 IdObject = 0;
        uint32 NbDest = 0;
        DefinitionObject * pLastDefIt;

        do
        {
            Bar.step();
            Field * pFields = pResult->Fetch();

            if (!GetDestination(pFields[5].GetUInt32()))
            {
                outstring_log("SD2P >> Destination introuvable (DestID: %u).", pFields[0].GetUInt32());
                continue;
            }

            if (!IsValidData(pFields[4].GetUInt32(), (Relation)pFields[0].GetUInt8(),
                             pFields[1].GetUInt32(), pFields[2].GetUInt64(), pFields[3].GetUInt32()))
                continue;

            if (IdObject != pFields[4].GetUInt32())
            {
                IdObject = pFields[4].GetUInt32();
                DefinitionObject DefIt(IdObject, (Relation)pFields[0].GetUInt8(), pFields[1].GetUInt8());
                pLastDefIt = &MDefObject.insert(MDefObject_t::value_type(IdObject, DefIt)).first->second;
            }

            DestObjectTele Dest =
            {
                pFields[5].GetUInt32(),      // DestId
                pFields[2].GetUInt64(),      // Data0
                pFields[3].GetUInt32(),      // Data1
            };

            pLastDefIt->AddDest(Dest);
            ++NbDest;
        } while (pResult->NextRow());

        delete pResult;
        outstring_log("");
        outstring_log(">> %u object_teleport charge(s).", NbDest);
    } else outstring_log("ATTENTION >> 0 object_teleport charge.");
}
const Destination * CAT::GetDest(const uint32 &DestId) const
{
    return GetDestination(m_VDest[DestId]);
}
Exemple #22
0
	String GetTo() {
		ostringstream os;
		os << GetDestination();
		return os.str();
	}
Exemple #23
0
void
Application::Start ()
{
#ifdef TEST_START_APPLICATION
  std::cout << "Start Application: src: " << GetSource ()->GetIDNetworkNode ()
		  << " dst: " << GetDestination ()->GetIDNetworkNode () << std::endl;
#endif

  // 1 - create radio bearer
  m_radioBearer = new RadioBearer ();
  //std::cout<<"RB"<<std::endl;//memorytest
  m_radioBearer->GetRlcEntity ()->SetRlcEntityIndex (GetApplicationID ());


  if (GetSource ()->GetNodeType() == NetworkNode::TYPE_UE)
    {
	  //create an UL radio bearer between UE and targetENB
	  UserEquipment* ue = (UserEquipment*) GetSource ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);

#ifdef TEST_START_APPLICATION
      std::cout << "Create UL radio bearer bewtween: " << GetSource ()->GetIDNetworkNode ()
		  << " and " << ue->GetTargetNode ()->GetIDNetworkNode () << std::endl;
#endif

	  m_radioBearer->SetSource (ue);
	  m_radioBearer->SetDestination (ue->GetTargetNode ());
	  m_radioBearer->SetClassifierParameters (GetClassifierParameters ());
	  m_radioBearer->SetApplication (this);
	  m_radioBearer->SetQoSParameters (GetQoSParameters ());
    }
  else if (GetSource ()->GetNodeType() == NetworkNode::TYPE_GW
		  ||
		  GetSource ()->GetNodeType() == NetworkNode::TYPE_ENODEB
		  ||
		  GetSource ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION)
    {
	  //create an DL radio bearer between targetENB and UE
	  UserEquipment* ue = (UserEquipment*) GetDestination ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);

#ifdef TEST_START_APPLICATION
      std::cout << "Create DL radio bearer bewtween: " << ue->GetTargetNode ()->GetIDNetworkNode ()
    		  << " and " << ue->GetIDNetworkNode ()  << std::endl;
#endif

	  m_radioBearer->SetSource (ue->GetTargetNode ());
	  m_radioBearer->SetDestination (ue);
	  m_radioBearer->SetClassifierParameters (GetClassifierParameters ());
	  m_radioBearer->SetApplication (this);
	  m_radioBearer->SetQoSParameters (GetQoSParameters ());
    }

  m_radioBearer->GetSource ()->GetProtocolStack ()->GetRrcEntity ()->AddRadioBearer (m_radioBearer);


  // 2 - create application sink
  m_applicationSink = new ApplicationSink ();
  //std::cout<<"AS"<<std::endl;//memorytest
  m_applicationSink->SetClassifierParameters (GetClassifierParameters ());
  m_applicationSink->SetSourceApplication (this);


  // 3 - create radio bearer sink
  m_bearerSink = new RadioBearerSink ();
  //std::cout<<"RBS"<<std::endl;//memorytest
  m_bearerSink->GetRlcEntity ()->SetRlcEntityIndex (GetApplicationID ());
  m_bearerSink->SetApplication (m_applicationSink);
  m_bearerSink->SetClassifierParameters (GetClassifierParameters ());
  m_bearerSink->SetQoSParameters (GetQoSParameters ());
  if (GetSource ()->GetNodeType() == NetworkNode::TYPE_UE)
    {
	  UserEquipment* ue = (UserEquipment*) GetSource ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);
	  m_bearerSink->SetSource (ue);
	  m_bearerSink->SetDestination (ue->GetTargetNode ());
    }
  else if (GetSource ()->GetNodeType() == NetworkNode::TYPE_GW || GetSource ()->GetNodeType() == NetworkNode::TYPE_ENODEB
		  || GetSource ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION)
    {
	  UserEquipment* ue = (UserEquipment*) GetDestination ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);
	  m_bearerSink->SetSource (ue->GetTargetNode ());
	  m_bearerSink->SetDestination (ue);
    }


  // 4 - add in radio bearer a pointer to the radio bearer sink
  m_radioBearer->GetDestination() ->GetProtocolStack ()->GetRrcEntity ()->AddRadioBearerSink(m_bearerSink);
  m_applicationSink->SetRadioBearerSink (m_bearerSink);


  // 4 attach UE on the UL or DL channel
  if (GetSource ()->GetNodeType() == NetworkNode::TYPE_UE)
    {
	  UserEquipment* ue = (UserEquipment*) GetSource ();
/*mouan
	  LteChannel *ch = ue->GetTargetNode ()->GetPhy ()->GetUlChannel ();

	  if (!ch->IsAttached (ue))
	    {
		  ch->AddDevice (ue);
	    }
mouan end*/

	  ue->MakeActive ();
    }
  else if (GetSource ()->GetNodeType() == NetworkNode::TYPE_GW || GetSource ()->GetNodeType() == NetworkNode::TYPE_ENODEB
		  || GetSource ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION)
    {
	  UserEquipment* ue = (UserEquipment*) GetDestination ();
	  LteChannel *ch = ue->GetTargetNode ()->GetPhy ()->GetDlChannel ();

	  if (!ch->IsAttached (ue))
	    {
		  ch->AddDevice (ue);
	    }

	  ue->MakeActive ();
    }

#ifdef TEST_START_APPLICATION
  std::cout << "CREATED RADIO BEARER " << m_radioBearer->GetApplication ()->GetApplicationID ()
		  << " BETWEEN "
		  << m_radioBearer->GetSource ()->GetIDNetworkNode () << " and "
		  << m_radioBearer->GetDestination () ->GetIDNetworkNode ()<< std::endl;
#endif

  DoStart ();
}